QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501363 | #5521. Excellent XOR Problem | Sakib_Safwan | WA | 0ms | 3768kb | C++20 | 3.1kb | 2024-08-02 17:13:54 | 2024-08-02 17:13:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
//#define int long long
// Don't Start typing till you complete the idea.
// Check these things for WA and before submitting
// 1. Did you clear all the global arrays
// 2. Did you checked your <= >= < >
// 3. Did you take the input properly. Did you use break or return while taking input?
// 4. Did you divide by 0.
// 5. Check array , vector , etc size
// 6. in the while loop did you miss something that would cause infinite loop?
// 7. Did you save your dp?
// 8. Are you trying to use something after deleting it?
// 9. Did you read the problem statement wrong?
// 10. Did you check the constrains of the problem properly
// 11. Did you checked for smaller cases like 1 , 0 , etc
// 12. Is it something to with overflow?
// 13. Did you initialized all the variables properly?
// 14. Did you use the formulas correctly?
// STRESS TESTING !!!!!! STRESS TESTING !!!!!
// STRESS Testing Not working?
// Stress test for multiple cases?
// Stress test for big inputs?
// Stress test for really small inputs?
// Even then if it doesn't work -> Did you wrote the wrong Brute force code
// Check these things if you are not generating ideas
// 1. Did you try thinking it in reverse?
// 2. Read the problem statement again
// 3. Check the constraints again
// 4. Try smaller cases in notebook and try to expand
// 5. Think about invariants
// 6. Think simpler ideas maybe?
// 7. Think brute force and try to get something out of it.
// 8. Maybe take a deep breath and take a break for few minutes and drink some water? :3
void GG()
{
int n;
cin >> n;
vector<int> v(n);
vector<int> nz;
ll tot_xor = 0;
set<int> st;
for(auto &x : v){
cin >> x;
tot_xor ^= x;
if(x != 0) nz.pb(x) , st.insert(x);
}
if(n == 2 && tot_xor == 0){cout << "NO" << endl; return;}
if(tot_xor != 0){
cout << "YES" << endl;
cout << 2 << endl;
cout << 1 << ' ';
for(int i = 0; i < n; i++){
if(v[i] != 0) {
cout << i + 1 << endl;
cout << i + 2 << ' ' << n << endl;
break;
}
}
return;
}
if(st.size() <= 1){
cout << "NO" << endl;
return;
}
vector<pair<int,int>> ans;
pair<int,int> p1;
p1.first = 1;
for(int i = 0; i < n; i++){
if(v[i] != 0) {p1.second = i + 1; break;}
}
ans.pb(p1);
int bad = v[p1.second - 1];
p1.first = p1.second + 1;
for(int i = p1.second; i < n; i++){
if(v[i] != 0 && v[i] != bad){
p1.second = i + 1;
ans.pb(p1);
p1.first = p1.second + 1;
p1.second = n;
ans.pb(p1);
break;
}
}
if(ans.size() >= 3){
cout << "YES" << endl;
for(auto [l , r] : ans) cout << l << ' ' << r << endl;
}
else cout << "NO" << endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int ttc=1;
cin>>ttc;
//int cnt=0;
while(ttc--)
{
//cout<<"Case "<<++cnt<<": ";
GG();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3768kb
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 1 1 2 2 3 3 YES 2 1 1 2 5 NO
result:
wrong answer Integer 1 violates the range [2, 3] (test case 2)