/ SeriousOJ /

Record Detail

Accepted


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

Code

#include <iostream>
#include <vector>
using namespace std;

bool cD(const vector<int>& x, const vector<int>& y) {
    bool t[10] = {false};
    bool o[10] = {false};

    for (int d : x) t[d] = true;
    for (int d : y) o[d] = true;

    for (int d = 1; d <= 31; ++d) {
        int a = d / 10;
        int b = d % 10;
        if (!t[a] || !o[b]) return false;
    }
    return true;
}

int main() {
    int T;
    cin >> T;

    while (T--) {
        int N, M;
        cin >> N >> M;

        vector<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];

        if (cD(x, y)) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }
    }

    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 14:58:14
Judged At
2025-01-02 14:58:14
Judged By
Score
100
Total Time
31ms
Peak Memory
1.27 MiB