QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#79880 | #5521. Excellent XOR Problem | UCSC_Ravioli# | WA | 2ms | 3476kb | C++20 | 1.4kb | 2023-02-21 04:40:21 | 2023-02-21 04:40:24 |
Judging History
answer
// qdd on Feb 20, 2023
#ifdef qdd
#include <ringo>
#else
#include <bits/stdc++.h>
#define dbg(...)
#define dbgr(x, y)
#endif
using namespace std;
using ll = long long;
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (T& x : v) is >> x;
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
bool f = 0;
for (const T& x : v) (f ? os << ' ' : os) << x, f = 1;
return os;
}
void say(bool tag) { cout << (tag ? "YES\n" : "NO\n"); }
void sol() {
int n;
cin >> n;
vector<int> a(n);
cin >> a;
int xor_all = 0;
for (int i = 0; i < n; i++) {
xor_all ^= a[i];
}
if (xor_all != 0) {
cout << "YES\n2\n";
cout << 1 << ' ' << 1 << '\n' << 2 << ' ' << n << '\n';
return;
}
int L = a[0];
for (int i = 1; i < n - 1; i++) {
if (L != xor_all) {
int M = a[i];
int R = xor_all ^ L ^ M;
for (int j = i + 1; j < n; j++) {
if (L != M && L != R && M != R) {
cout << "YES\n3\n";
cout << 1 << ' ' << j << '\n';
cout << j + 1 << ' ' << j + 1 << '\n';
cout << j + 2 << ' ' << n << '\n';
return;
}
M ^= a[j];
R ^= a[j];
}
}
}
cout << "NO\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
sol();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3476kb
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 2 3 3 4 3 YES 2 1 1 2 5 NO
result:
wrong answer Integer 4 violates the range [1, 3] (test case 2)