QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#430308#5521. Excellent XOR Problem36champWA 0ms3524kbC++201.1kb2024-06-03 17:34:162024-06-03 17:34:16

Judging History

你现在查看的是最新测评结果

  • [2024-06-03 17:34:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2024-06-03 17:34:16]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int t = 1;
	cin >> t;
    while(t-->0)
    {
        int n;
        cin >> n;

        vector<ll> a(n);
        for(int i=0; i<n; i++) cin >> a[i];

        ll x = 0;
        for(int i=0; i<n; i++) x ^= a[i];

        if(x!=0) cout << "YES\n2\n1 1\n2 " << n << "\n";
        else
        {
            int index1 = 0;
            while(index1 < n && a[index1] == 0) index1++;

            int index2 = index1 + 1;
            while(index2 < n && (x == 0 || x == a[index1]))
            {
                x ^= a[index2];
                index2++;
            }

            if(index2 < n)
            {
                cout << "YES\n";
                cout << "1 " << index1 + 1 << "\n";
                cout << index1 + 2 << " " << index2 << "\n";
                cout << index2 + 1 << " " << n << "\n";
            }
            else cout << "NO\n";
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
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
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)