QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#81386#5521. Excellent XOR ProblemSmallbasic#WA 3ms5548kbC++141.0kb2023-02-25 14:43:052023-02-25 14:43:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-25 14:43:43]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5548kb
  • [2023-02-25 14:43:05]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

inline int read() {
	register int s = 0, f = 1; register char ch = getchar();
	while (!isdigit(ch)) f = (ch == '-' ? -1 : 1), ch = getchar();
	while (isdigit(ch)) s = (s * 10) + (ch & 15), ch = getchar();
	return s * f;
}

int n, a[N], top;
struct node {
	int val, l, r;
	inline node() { }
	inline node(int V, int L, int R) : val(V), l(L), r(R) { } 
	inline void merge(const node &b) {
		r = b.r;
		val ^= b.val;
	}
} stk[N];
map<int, int> vis;

int main() {
	int T = read();
	while (T--) {
		n = read(); vis.clear();
		for (int i = 1; i <= n; ++i) a[i] = read();
		top = 0;
		for (int i = 1; i <= n; ++i) {
			stk[++top] = node(a[i], i, i);
			++vis[a[i]];
			while (vis[stk[top].val] >= 2) {
				--vis[stk[top].val];
				stk[top - 1].merge(stk[top]);
				--top;
			}
		}
		if (top == 1) puts("NO");
		else {
			puts("YES");
			for (int i = 1; i <= top; ++i) printf("%d %d\n", stk[i].l, stk[i].r);
		}
	} return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 5548kb

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 2
3 3
4 4
5 5
NO

result:

wrong answer Integer 1 violates the range [2, 3] (test case 2)