Accepted
Code
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,m;
cin>>n>>m;
int x[n],y[m];
for(int i=0; i<n; i++)
{
cin>>x[i];
}
for(int i=0; i<m; i++)
{
cin>>y[i];
}
int can = 1;
for(int j=1; j<=31; j++)
{
int first = j/10;
int second = j%10;
int found1 = 1;
for(int i=0; i<n; i++)
{
if(x[i]==first )
{
found1=0;
break;
}
}
int found2 = 1;
for(int i=0; i<m; i++)
{
if(y[i]==second )
{
found2=0;
break;
}
}
if(found1!=0 || found2!=0)
{
can = 0;
break;
}
}
if(can==1)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
}
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:22:32
- Judged At
- 2025-01-02 15:22:32
- Judged By
- Score
- 100
- Total Time
- 31ms
- Peak Memory
- 1.281 MiB