QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409546#8338. Quad Kingdoms ChessbigJWA 30ms3756kbC++231.4kb2024-05-12 11:06:102024-05-12 11:06:10

Judging History

你现在查看的是最新测评结果

  • [2024-05-12 11:06:10]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:3756kb
  • [2024-05-12 11:06:10]
  • 提交

answer

#include <bits/stdc++.h>

int main() {
    int n1, n2, m;
    std::map<int, int> cnt1;
    std::map<int, int> cnt2;

    scanf("%d", &n1);
    std::vector<int> a(n1);
    for (int i = 0; i < n1; i++) {
        scanf("%d", &a[i]);
        cnt1[a[i]]++;
    }

    scanf("%d", &n2);
    std::vector<int> b(n2);
    for (int i = 0; i < n2; i++) {
        scanf("%d", &b[i]);
        cnt2[b[i]]++;
    }

    auto work = [&]() {
        if (a.back() != b.back()) {
            return false;
        }
        if (a == b) {
            return true;
        }
        return  cnt1.rbegin()->second == cnt2.rbegin()->second;
    };

    scanf("%d", &m);
    while (m--) {
        int o, x, y;
        scanf("%d%d%d", &o, &x, &y);
        x--;
        if (o == 1) {
            if (--cnt1[a[x]] == 0) {
                cnt1.erase(a[x]);
            }
            a[x] = y;
            cnt1[a[x]]++;
        } else {
            if (--cnt2[b[x]] == 0) {
                cnt2.erase(b[x]);
            }
            b[x] = y;
            cnt2[b[x]]++;
        }
        // for (int j = 0; j < n1; j++) {
        //     printf("%d%c", a[j], " \n"[j == n1 - 1]);
        // }
        // for (int j = 0; j < n2; j++) {
        //     printf("%d%c", b[j], " \n"[j == n2 - 1]);
        // }
        puts(work() ? "YES" : "NO");
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3756kb

input:

5
1 2 3 4 5
5
5 4 3 2 1
8
1 1 5
1 4 2
1 2 4
1 5 1
1 5 5
2 1 4
2 3 5
2 5 5

output:

NO
NO
NO
YES
NO
NO
NO
YES

result:

ok 8 tokens

Test #2:

score: -100
Wrong Answer
time: 30ms
memory: 3588kb

input:

1
2
6
2 1 1 1 1 1
200000
2 6 2
1 1 1
1 1 1
1 1 2
2 1 1
1 1 2
1 1 1
2 4 1
2 1 2
1 1 1
1 1 2
2 5 1
1 1 1
1 1 2
1 1 1
2 6 1
1 1 2
1 1 2
1 1 2
2 3 1
1 1 1
2 1 1
2 6 2
1 1 2
2 4 1
1 1 2
2 6 1
1 1 2
1 1 1
2 5 2
2 6 2
1 1 1
2 4 2
2 5 2
2 6 2
1 1 1
2 5 1
2 6 2
1 1 2
1 1 1
1 1 1
2 4 1
1 1 2
1 1 2
1 1 2
2 3 2...

output:

NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
N...

result:

wrong answer 16th words differ - expected: 'NO', found: 'YES'