QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102449#5521. Excellent XOR ProblemYldar#WA 135ms13336kbC++171.2kb2023-05-03 13:20:322023-05-03 13:20:35

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 13:20:35]
  • 评测
  • 测评结果:WA
  • 用时:135ms
  • 内存:13336kb
  • [2023-05-03 13:20:32]
  • 提交

answer

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

using namespace std;

const int inf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3fll;
inline long long read(){
    long long s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

void doit(){
    int n=read();
    map<int,int>q;
    vector<int>a(n+1);
    int ff=0;
    long long k=0;
    for(int i=1;i<=n;i++) {
        a[i]=read();
        k=k^a[i];
        if (q[a[i]]) ff=1;
        q[a[i]]++;
        if (q[a[i]]==n) {
            printf("NO\n");
            return ;
        }
    }
     printf("YES\n");
    if (k!=0){
        printf("2\n");
        printf("1 1\n2 %d\n",n);
        return;
    }
    k=k^a[1];
    printf("3\n");
    long long now=0;
    for(int i=2;i<=n-1;i++){
        now=now^a[i];
        if (now!=a[1]&&(k^now)!=a[1]&&(k^now)!=now) {
            printf("1 1\n2 %d\n%d %d\n",i,i+1,n);
            return ;
        }
    }
}

int  main(){
    // freopen("input.in","r",stdin);
    // freopen("output.out","w",stdout);
    int T=read();
    while(T--){
    doit();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3644kb

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 1
2 5
NO

result:

ok Correct (4 test cases)

Test #2:

score: 0
Accepted
time: 3ms
memory: 3788kb

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 1
2 200000

result:

ok Correct (1 test case)

Test #3:

score: 0
Accepted
time: 121ms
memory: 13260kb

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: 135ms
memory: 13336kb

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 1
2 200000

result:

ok Correct (1 test case)

Test #5:

score: 0
Accepted
time: 12ms
memory: 3756kb

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 1
2 139152
139153 200000

result:

ok Correct (1 test case)

Test #6:

score: -100
Wrong Answer
time: 14ms
memory: 3752kb

input:

1
200000
917884074 0 917884074 917884074 0 0 0 917884074 917884074 0 917884074 0 0 0 917884074 0 917884074 917884074 0 917884074 0 917884074 0 917884074 0 917884074 0 0 917884074 0 0 0 0 917884074 0 0 917884074 0 0 917884074 0 0 0 917884074 0 0 917884074 917884074 917884074 0 917884074 917884074 917...

output:

YES
3

result:

wrong output format Unexpected end of file - int32 expected (test case 1)