QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140620#5521. Excellent XOR ProblemPhantomThreshold#WA 16ms5084kbC++201.2kb2023-08-16 14:15:132023-08-16 14:15:17

Judging History

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

  • [2023-08-16 14:15:17]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:5084kb
  • [2023-08-16 14:15:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=200000;
ll T,n;
ll a[maxn+50];

int main(){
	ios_base::sync_with_stdio(false);
	cin >> T;
	for (;T--;){
		cin >> n;
		for (int i=1;i<=n;i++) cin >> a[i];
		
		ll sum=0;
		for (int i=1;i<=n;i++) sum^=a[i];
		if (sum!=0){
			cout << "YES" << "\n";
			cout << 2 << "\n";
			cout << 1 << " " << 1 << "\n";
			cout << 2 << " " << n << "\n";
			continue;
		}
		int pos=0;
		for (int i=1;i<=n;i++) if (a[i]!=a[1]){pos=i;break;}
		
		if (pos==0){
			cout << "NO" << "\n";
			continue;
		}
		
		if (pos%2==1){
			vector<pair<int,int>> ans;
			if (1<=pos-2) ans.emplace_back(1,pos-2);
			if (pos-1<=pos) ans.emplace_back(pos-1,pos);
			if (pos+1<=n) ans.emplace_back(pos+1,n);
			cout << "YES" << "\n";
			cout << ans.size() << "\n";
			for (auto [x,y]:ans) cout << x << " " << y << "\n";
			continue;
		}
		else{
			vector<pair<int,int>> ans;
			if (1<=pos-1) ans.emplace_back(1,pos-1);
			if (pos<=pos) ans.emplace_back(pos,pos);
			if (pos+1<=n) ans.emplace_back(pos+1,n);
			cout << "YES" << "\n";
			cout << ans.size() << "\n";
			for (auto [x,y]:ans) cout << x << " " << y << "\n";
			continue;
		}
	}
	return 0;
} 

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3544kb

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
YES
2
1 1
2 5
NO

result:

ok Correct (4 test cases)

Test #2:

score: 0
Accepted
time: 13ms
memory: 5032kb

input:

1
200000
0 0 104990627 0 104990627 0 0 0 0 104990627 0 104990627 0 0 104990627 104990627 0 0 0 0 0 104990627 0 0 0 104990627 104990627 104990627 0 104990627 0 104990627 104990627 0 104990627 0 0 0 104990627 104990627 0 0 104990627 104990627 0 0 104990627 0 0 0 0 0 104990627 104990627 0 0 0 0 0 10499...

output:

YES
2
1 1
2 200000

result:

ok Correct (1 test case)

Test #3:

score: 0
Accepted
time: 11ms
memory: 5036kb

input:

1
200000
916550535 1039111536 183367143 845311658 473404911 844600350 249761080 860927112 268559756 661297994 448456545 184790162 804023458 655065019 442145717 130497524 509071033 644651807 1039510287 766490362 514960668 612238468 863513676 417538457 839195481 901404895 760875212 983171045 343221187...

output:

YES
3
1 1
2 2
3 200000

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 16ms
memory: 5084kb

input:

1
200000
697100980 63360185 3577101 75632048 903073319 644702701 1017474476 268785811 6091842 227390753 270800416 554896940 318364388 526066510 354510498 1034952286 613138496 176305121 384248064 715019967 999545181 91222841 1063728923 665773338 354670745 473570604 220064105 301115885 1038664738 3094...

output:

YES
2
1 1
2 200000

result:

ok Correct (1 test case)

Test #5:

score: -100
Wrong Answer
time: 11ms
memory: 5024kb

input:

1
200000
446225258 446225258 446225258 446225258 0 0 446225258 446225258 0 446225258 0 0 446225258 0 446225258 0 446225258 446225258 446225258 0 446225258 0 0 446225258 0 0 446225258 446225258 446225258 446225258 0 0 0 446225258 0 446225258 446225258 0 0 0 0 446225258 446225258 446225258 446225258 0...

output:

YES
3
1 3
4 5
6 200000

result:

FAIL all xors must be different (test case 1)