/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 18ms 532.0 KiB
#3 Accepted 16ms 532.0 KiB
#4 Accepted 4ms 532.0 KiB
#5 Accepted 30ms 532.0 KiB
#6 Accepted 31ms 1.281 MiB
#7 Accepted 31ms 1.062 MiB

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