QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#99423#5521. Excellent XOR Problemwillow#WA 2ms3592kbC++14799b2023-04-22 13:25:402023-04-22 13:25:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-22 13:25:42]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3592kb
  • [2023-04-22 13:25:40]
  • 提交

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)