QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#78586 | #5521. Excellent XOR Problem | BoaHancock | WA | 64ms | 6276kb | C++20 | 1.1kb | 2023-02-19 16:42:10 | 2023-02-19 16:42:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n;
cin >> n;
vector<int> v(n + 1), xsum(n + 1, 0);
for(int i = 1;i <= n; ++ i) {
cin >> v[i];
xsum[i] = xsum[i - 1] ^ v[i];
}
if(xsum[n] == 0) {
int id = n;
while(xsum[id] == 0) {
-- id;
}
for(int i = 1; i < id; ++ i) {
int x = xsum[i];
int y = xsum[id - 1] ^ x;
if(x != 0 && x != y) {
cout << "Yes" << '\n' << 3 << '\n';
cout << 1 << ' ' << i << '\n' << i + 1 << ' ' << id << '\n' << id + 1 << ' ' << n << '\n';
return;
}
}
}
int x, y;
for(int i = 1; i < n; ++ i) {
x = xsum[i];
y = xsum[n] ^ x;
if(x != y) {
cout << "Yes" << '\n' << 2 << '\n';
cout << 1 << ' ' << i << '\n' << i + 1 << ' ' << n << '\n';
return;
}
}
cout << "No" << '\n';
}
int32_t main() {
int T = 1;
cin >> T;
while(T --) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3392kb
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: 44ms
memory: 6168kb
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: 61ms
memory: 6276kb
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 199999 200000 200000
result:
ok Correct (1 test case)
Test #4:
score: 0
Accepted
time: 64ms
memory: 6168kb
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: 45ms
memory: 6180kb
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 1 2 199999 200000 200000
result:
FAIL all xors must be different (test case 1)