QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#554111#5521. Excellent XOR ProblemRichw818WA 0ms3592kbC++201.2kb2024-09-09 06:10:582024-09-09 06:10:58

Judging History

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

  • [2024-09-09 06:10:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2024-09-09 06:10:58]
  • 提交

answer

#include <bits/stdc++.h>

void solve() {
    int n;
    std::cin >> n;
    int x = 0;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        x ^= a[i];
    }
    if (x) {
        std::cout << "YES\n";
        std::cout << 2 << "\n";
        std::cout << 1 << " " << 1 << "\n";
        std::cout << 2 << " " << n << "\n";
        return;
    }
    x = 0;
    int firstNonZero = -1;
    for (int i = 0; i < n; i++) {
        if (a[i] != 0) {
            firstNonZero = i;
            break;
        }
    }
    if (firstNonZero == -1) {
        std::cout << "NO\n";
        return;
    }
    for (int i = firstNonZero + 1; i < n; i++) {
        x ^= a[i];
        if (x != a[firstNonZero] && x != 0) {
            std::cout << "YES\n";
            std::cout << 3 << "\n";
            std::cout << 1 << " " << firstNonZero + 1 << "\n";
            std::cout << firstNonZero + 2 << " " << i + 1 << "\n";
            std::cout << i + 2 << " " << n << "\n";
        }
    }
    std::cout << "NO\n";
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3592kb

input:

4
2
0 0
3
1 2 3
5
16 8 4 2 1
6
42 42 42 42 42 42

output:

NO
YES
3
1 1
2 2
3 3
NO
YES
2
1 1
2 5
NO

result:

wrong answer Jury found the answer but participant didn't (test case 3)