/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 328.0 KiB
#2 Accepted 9ms 540.0 KiB
#3 Accepted 8ms 436.0 KiB
#4 Accepted 2ms 284.0 KiB
#5 Accepted 17ms 516.0 KiB
#6 Accepted 17ms 1.254 MiB
#7 Accepted 27ms 1.176 MiB

Code

#include <stdio.h>

int contains(int arr[], int size, int value) {
    for (int i = 0; i < size; i++) {
        if (arr[i] == value) {
            return 1;
        }
    }
    return 0;
}

int can_form_all_dates(int X[], int N, int Y[], int M) {
    for (int date = 1; date <= 31; date++) {
        int tens = date / 10;
        int ones = date % 10;
        if (!contains(X, N, tens) || !contains(Y, M, ones)) {
            return 0;
        }
    }
    return 1;
}

int main() {
    int T;
    scanf("%d", &T);

    while (T--) {
        int N, M;
        scanf("%d %d", &N, &M);

        int X[N], Y[M];
        for (int i = 0; i < N; i++) {
            scanf("%d", &X[i]);
        }
        for (int i = 0; i < M; i++) {
            scanf("%d", &Y[i]);
        }

        if (can_form_all_dates(X, N, Y, M)) {
            printf("YES\n\n");
        } else {
            printf("NO\n\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 15:13:40
Judged At
2025-01-02 15:13:40
Judged By
Score
100
Total Time
27ms
Peak Memory
1.254 MiB