QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#554111 | #5521. Excellent XOR Problem | Richw818 | WA | 0ms | 3592kb | C++20 | 1.2kb | 2024-09-09 06:10:58 | 2024-09-09 06:10:58 |
Judging History
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;
}
详细
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)