Time Exceeded
Code
#include <iostream>
#include <vector>
#include <set>
using namespace std;
bool ok(const vector<int>& l1, const vector<int>& l2) {
set<int> s;
for (int x : l1)
{
for (int y : l2)
{
int date = x * 10 + y;
if (date >= 1 && date <= 31)
{
s.insert(date);
}
}
}
return s.size() == 31;
}
int main()
{
int t;
cin >> t;
while (t--)
{
int n, m;
cin >> n >> m;
vector<int> l1(n), l2(m);
for (int i = 0; i < n; i++)
{
cin >> l1[i];
}
for (int i = 0; i < m; i++)
{
cin >> l2[i];
}
if (ok(l1, l2))
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1153 Is Date Possible?
- Contest
- Happy New Year 2025
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-01-02 15:21:23
- Judged At
- 2025-01-02 15:21:23
- Judged By
- Score
- 50
- Total Time
- ≥1099ms
- Peak Memory
- ≥1.27 MiB