/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 284.0 KiB
#2 Accepted 11ms 324.0 KiB
#3 Accepted 43ms 424.0 KiB
#4 Accepted 13ms 432.0 KiB
#5 Time Exceeded ≥1001ms ≥284.0 KiB
#6 Time Exceeded ≥1100ms ≥1.02 MiB

Code

#include <stdio.h>
#include <stdbool.h>
#include <string.h>

bool canFormAllDates(int N, int M, int* list1, int* list2) {
    bool formedDates[31] = {false};

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            int date = list1[i] * 10 + list2[j];
            if (date >= 1 && date <= 31) {
                formedDates[date-1] = true;
            }
        }
    }

    for (int i = 0; i < 31; i++) {
        if (!formedDates[i]) {
            return false;
        }
    }
    return true;
}

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

    char results[T][4]; // Array to store results (either "YES" or "NO")

    for (int t = 0; t < T; t++) {
        int N, M;
        scanf("%d %d", &N, &M);

        int list1[N], list2[M];

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

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

        if (canFormAllDates(N, M, list1, list2)) {
            strcpy(results[t], "YES");
        } else {
            strcpy(results[t], "NO");
        }
    }

    // Print all results, each on a new line
    for (int t = 0; t < T; t++) {
        printf("%s\n", results[t]);
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1153 Is Date Possible?
Contest
Happy New Year 2025
Language
C99 (GCC 13.2.0)
Submit At
2025-01-02 15:02:04
Judged At
2025-01-02 15:02:04
Judged By
Score
50
Total Time
≥1100ms
Peak Memory
≥1.02 MiB