/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 21ms 532.0 KiB
#3 Accepted 17ms 564.0 KiB
#4 Accepted 4ms 324.0 KiB
#5 Accepted 48ms 532.0 KiB
#6 Accepted 33ms 1.297 MiB
#7 Accepted 32ms 1.27 MiB

Code

#include <bits/stdc++.h>

using namespace std;

bool ok(const vector<int>& list1, const vector<int>& list2) {
    unordered_set<int> digits1(list1.begin(), list1.end());
    unordered_set<int> digits2(list2.begin(), list2.end());

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

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