QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409577#8338. Quad Kingdoms ChessbigJWA 32ms3628kbC++232.2kb2024-05-12 11:39:072024-05-12 11:39:08

Judging History

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

  • [2024-05-12 11:39:08]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:3628kb
  • [2024-05-12 11:39:07]
  • 提交

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 = [&]() {
        int v = a.back();
        if (a.back() != b.back()) {
            return false;
        }
        auto it1 = std::next(cnt1.find(v));
        auto it2 = std::next(cnt2.find(v));

        while (it1 != cnt1.end() && it2 != cnt2.end()) {
            if (it1->first != it2->first || it1->second != it2->second) {
                return false;
            }
            it1++, it2++;
        }
        if (it1 != cnt1.end() && it2 != cnt2.end()) {
            return false;
        }

        int i = n1 - 1;
        int j = n2 - 1;
        while (i - 1 >= 0 && a[i - 1] <= v) {
            i--;
        }
        while (j - 1 >= 0 && b[j - 1] <= v) {
            j--;
        }
        if (i != 0) {
            i--;
        }
        if (j != 0) {
            j--;
        }
        while (i < n1 && j < n2) {
            if (a[i] > b[j]) {
                j++;
            } else if (a[i] < b[j]) {
                i++;
            } else {
                i++, j++;
            }
        }
        return i == n1 && j == n2;
    };

    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]]++;
        }
        puts(work() ? "YES" : "NO");
    }

    // for (int i = 0; i < n1; i++) {
    //     printf("%d%c", a[i], " \n"[i == n1 - 1]);
    // }
    // for (int i = 0; i < n2; i++) {
    //     printf("%d%c", b[i], " \n"[i == n2 - 1]);
    // }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 32ms
memory: 3628kb

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
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
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
NO
N...

result:

ok 200000 tokens

Test #3:

score: 0
Accepted
time: 28ms
memory: 3600kb

input:

6
2 1 1 2 1 2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ES
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
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

wrong answer 32nd words differ - expected: 'YES', found: 'NO'