/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 21ms 324.0 KiB
#3 Accepted 19ms 556.0 KiB
#4 Accepted 5ms 324.0 KiB
#5 Accepted 38ms 604.0 KiB
#6 Accepted 32ms 1.27 MiB
#7 Accepted 33ms 1.273 MiB

Code

#include <bits/stdc++.h>
using namespace std;

bool ok(const vector<int>& l1, const vector<int>& l2)
{
    unordered_set<int> d1(l1.begin(), l1.end());
    unordered_set<int> d2(l2.begin(), l2.end());

    for (int i = 1; i <= 31; ++i) 
    {
        int tens = i / 10;
        int units = i % 10;
        if (d1.find(tens) == d1.end() || d2.find(units) == d2.end())
        {
            return false;
        }
    }
    return true;
}

int main() 
{
    
    int t ; cin >> t ; 
    while(t--)
    {
    int n , m ; cin >> n >> m ;
    vector<int> a(n) ,v(m);
    for(int i=0;i<n;i++) cin >> a[i];
    
     for(int i=0;i<m;i++) cin >> v[i] ;
     
    if (ok(a,v)) 
    {
        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:41:05
Judged At
2025-01-02 15:41:05
Judged By
Score
100
Total Time
38ms
Peak Memory
1.273 MiB