QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#99423 | #5521. Excellent XOR Problem | willow# | WA | 2ms | 3592kb | C++14 | 799b | 2023-04-22 13:25:40 | 2023-04-22 13:25:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int T, n, a[maxn];
int main() {
for(scanf("%d", &T); T --; ) {
scanf("%d", &n);
int s = 0, nz = 0;
for(int i = 1; i <= n; ++ i) {
scanf("%d", &a[i]), s ^= a[i];
if(a[i]) {
if(nz > 0) {
if(a[i] != nz)
nz = -1;
}
else if(nz == 0) {
nz = a[i];
}
}
}
if(nz > 0 && !s) {
puts("NO");
continue;
}
else if(s) {
puts("YES");
printf("1 1\n2 %d\n", n);
continue;
}
int l = 1;
while(l <= n && !a[l])
l ++;
int r = l + 1, x = a[r];
while(r <= n && x == a[l] && x == 0)
++ r, x ^= a[r];
if(r > n) {
puts("NO");
continue;
}
puts("YES");
printf("%d %d\n%d %d\n%d %d\n", 1, l, l + 1, r, r + 1, n);
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
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 1 1 2 2 3 3 YES 1 1 2 5 NO
result:
wrong answer Integer 1 violates the range [2, 3] (test case 2)