QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#93831 | #5521. Excellent XOR Problem | Asad_Bin | WA | 2ms | 3508kb | C++17 | 3.3kb | 2023-04-03 04:33:49 | 2023-04-03 04:33:52 |
Judging History
answer
// . . . Bismillahir Rahmanir Rahim . . .
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifndef ONLINE_JUDGE
#define dbg_out cout
#define debug(...) dbg_out << "DBG )> "; __f(#__VA_ARGS__, __VA_ARGS__);
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> pr) { out << "{ " << pr.first << ", " << pr.second << " }"; return out; }
template<typename T1> ostream& operator<<(ostream& out, vector<T1> vec) { out << "{ "; for (auto &x: vec) out << x << ", "; out << "}"; return out; }
template<typename T1, size_t size> ostream& operator<<(ostream& out, array<T1, size> arr) { out << "{ "; for (auto &x: arr) out << x << ", "; out << "}"; return out; }
template<typename T1, typename T2> ostream& operator<<(ostream& out, map<T1, T2> mp) { out << "{ ";for (auto &x: mp) out << x.first << ": " << x.second << ", "; out << "}"; return out; }
template <typename Arg1> void __f(const char* name, Arg1&& arg1) { while (isspace(name[0])) name++; (isalpha(name[0]) || name[0] == '_') ? dbg_out << name << ": " << arg1 << "\n" : dbg_out << arg1 << "\n"; dbg_out.flush();}
template <typename Arg1, typename... Args> void __f (const char* names, Arg1&& arg1, Args&&... args) { const char *comma = strchr(names + 1, ','); while (isspace(names[0])) names++; (isalpha(names[0]) || names[0] == '_') ? dbg_out.write(names, comma - names) << ": " << arg1 << " | " : dbg_out << arg1 << " | "; __f(comma + 1, args...);}
#else
#define debug(...)
#endif
ll gcd(ll a, ll b){ while (b){ a %= b; swap(a, b);} return a;}
ll lcm(ll a, ll b){ return (a/gcd(a, b)*b);}
ll ncr(ll a, ll b){ ll x = max(a-b, b), ans=1; for(ll K=a, L=1; K>=x+1; K--, L++){ ans = ans * K; ans /= L;} return ans;}
ll bigmod(ll a,ll b,ll mod){ if(b==0){ return 1;} ll tm=bigmod(a,b/2,mod); tm=(tm*tm)%mod; if(b%2==1) tm=(tm*a)%mod; return tm;}
ll egcd(ll a,ll b,ll &x,ll &y){ if(a==0){ x=0; y=1; return b;} ll x1,y1; ll d=egcd(b%a,a,x1,y1); x=y1-(b/a)*x1; y=x1; return d;}
ll modpow(ll a,ll p,ll mod) {ll ans=1;while(p){if(p%2)ans=(ans*a)%mod;a=(a*a)%mod;p/=2;} return ans;}
ll inverse_mod(ll n,ll mod) {return modpow(n,mod-2,mod);}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while(t--){
int n; cin >> n;
int ara[n];
for(int K = 0; K < n; K++) cin >> ara[K];
int x_or = 0;
for(int K = 0; K < n; K++) x_or ^= ara[K];
if(x_or){
int val = 0;
bool ok = 1;
for(int K = 0; K < n; K++){
val ^= ara[K]; x_or ^= ara[K];
if(val != x_or){
cout << "YES\n";
cout << 2 << "\n";
cout << 1 << ' '<< K+1 << "\n";
cout << K+2 << ' ' << n << "\n";
ok = 0;
break;
}
}
if(ok) cout << "NO\n";
}
else{
int val = 0;
bool ok = 1;
for(int K = 0; K < n-2; K++){
if(!ara[K]) continue;
x_or ^= ara[K];
val = 0;
for(int L = K+1; L < n; L++){
val ^= ara[L]; x_or ^= ara[L];
if(val != x_or && val != ara[K] && x_or != ara[K]){
cout << "YES\n";
cout << 2 << "\n";
cout << 1 << ' '<< K+1 << "\n";
cout << K+2 << ' ' << L+1 << "\n";
cout << L+2 << ' ' << n << "\n";
ok = 0;
break;
}
}
if(ok) cout << "NO\n";
ok = 0;
if(ara[K]) break;
}
if(ok) cout << "NO\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3508kb
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 2 1 1 2 2 3 3 YES 2 1 1 2 5 NO
result:
FAIL has to be a partition (test case 2)