QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#130913 | #5521. Excellent XOR Problem | tselmegkh# | WA | 71ms | 14172kb | C++20 | 2.3kb | 2023-07-25 17:08:38 | 2023-07-25 17:08:42 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
const int N = 2e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
void solve(){
int n;
cin >> n;
vi a(n + 1);
vi pref(n + 1);
map<int, int> pos;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int i = 1; i <= n; i++){
pref[i] = (pref[i - 1] ^ a[i]);
pos[pref[i]] = i;
}
if(pref[n] != 0){
cout << "YES\n2\n";
cout << 1 << ' ' << n - 1 << '\n';
cout << n << ' ' << n << '\n';
return;
} else {
set<int> s;
s.insert(pref[1]);
for(int j = 2; j <= n - 1; j++){
if(pref[j] != 0){
int x = (pref[n] ^ pref[j]);
bool flag1 = false, flag2 = false;
int val1, val2;
auto it = s.find(x);
if(it != s.end()){
val1 = (*it);
s.erase(it);
flag1 = true;
}
it = s.find(pref[n]);
if(it != s.end()){
val2 = (*it);
s.erase(it);
flag2 = true;
}
if(!s.empty()){
int val = pos[(*s.begin())];
cout << "YES\n3\n";
cout << 1 << ' ' << val << '\n';
cout << val + 1 << ' ' << j << '\n';
cout << j + 1 << ' ' << n << '\n';
return;
}
if(flag1)s.insert(val1);
if(flag2)s.insert(val2);
}
s.insert(pref[j]);
}
}
cout << "NO\n";
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
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: 1ms
memory: 3524kb
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 4 5 5 NO
result:
ok Correct (4 test cases)
Test #2:
score: 0
Accepted
time: 13ms
memory: 4620kb
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 199999 200000 200000
result:
ok Correct (1 test case)
Test #3:
score: 0
Accepted
time: 67ms
memory: 14108kb
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: 71ms
memory: 14172kb
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 199999 200000 200000
result:
ok Correct (1 test case)
Test #5:
score: -100
Wrong Answer
time: 18ms
memory: 4612kb
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 199999 200000 139152 139153 200000
result:
wrong answer Integer 139152 violates the range [200000, 200000] (test case 1)