Accepted
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
for(int i =0; i<t; i++)
{
int x,y;
cin>>x>>y;
set<int>a,b;
for(int j = 0; j<x; j++){
int aa;
cin>>aa;
a.insert(aa);
}
for(int j = 0; j<y; j++){
int aa;
cin>>aa;
b.insert(aa);
}
bool possible = true;
for (int date = 1; date <= 31; ++date) {
int tens = date / 10;
int units = date % 10;
if (a.find(tens) == a.end() || b.find(units) == b.end()) {
possible = false;
break;
}
}
if(possible)
{
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:09:13
- Judged At
- 2025-01-02 15:09:13
- Judged By
- Score
- 100
- Total Time
- 37ms
- Peak Memory
- 588.0 KiB