QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138369#6394. Turn on the LightSchi2oidWA 5ms13464kbC++14941b2023-08-11 16:41:262023-08-11 16:41:28

Judging History

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

  • [2023-08-11 16:41:28]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:13464kb
  • [2023-08-11 16:41:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int ask(int x){
	int ret;
	cout<<"? "<<x<<endl;
	cin>>ret;
	return ret;
}
int id[2][2000005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) id[0][i]=i;
	bool op=0;
	int bef=0;
	while(n>4){
		int p1=n/4,p2=n-n/4;
		int x=ask(id[op][p1]);
		if(x==bef){
			cout<<"! p1";
			return 0;
		}
		 int y=ask(id[op][p2]);
		 if(y==x){
		 	cout<<"! p2";
		 	return 0;
		 }
		 int delta=y-bef;
		 op^=1;
		 if(delta==0){
		 	n=p2-p1;
		 	int cnt=0;
		 	for(int i=p1+1;i<=p2;i++){
		 		id[op][++cnt]=id[op^1][i];
		 	}
		 }
		 else{
		 	n=n-p2+p1-1;
		 	int cnt=0;
		 	for(int i=1;i<p1;i++){
		 		id[op][++cnt]=id[op^1][i];
		 	}
		 	for(int i=p2+1;i<=n;i++){
		 		id[op][++cnt]=id[op^1][i];
		 	}
		 }
		 bef=y;
	}
	for(int i=1;i<=n;i++){
		int x=ask(id[op][i]);
		if(x==bef){
			cout<<"! "<<id[op][i];
			return 0;
		}
		bef=x;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3404kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: 0
Accepted
time: 1ms
memory: 5504kb

input:

10
1
0
1
0
1
1

output:

? 2
? 8
? 3
? 7
? 4
? 5
! 5

result:

ok Correct position at 5

Test #3:

score: 0
Accepted
time: 1ms
memory: 5452kb

input:

9
1
0
1
0
1
1

output:

? 2
? 7
? 3
? 6
? 4
? 5
! 5

result:

ok Correct position at 5

Test #4:

score: 0
Accepted
time: 1ms
memory: 5508kb

input:

8
1
0
1
1

output:

? 2
? 6
? 3
? 4
! 4

result:

ok Correct position at 4

Test #5:

score: 0
Accepted
time: 2ms
memory: 5464kb

input:

7
1
0
1
0
1
1

output:

? 1
? 6
? 2
? 5
? 3
? 4
! 4

result:

ok Correct position at 4

Test #6:

score: 0
Accepted
time: 1ms
memory: 5512kb

input:

6
1
0
1
1

output:

? 1
? 5
? 2
? 3
! 3

result:

ok Correct position at 3

Test #7:

score: 0
Accepted
time: 0ms
memory: 5512kb

input:

5
1
0
1
1

output:

? 1
? 4
? 2
? 3
! 3

result:

ok Correct position at 3

Test #8:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

score: 0
Accepted
time: 2ms
memory: 3460kb

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: 0
Accepted
time: 0ms
memory: 12616kb

input:

1000000
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
2

output:

? 250000
? 750000
? 375000
? 625000
? 437500
? 562500
? 468750
? 531250
? 484375
? 515625
? 492187
? 507813
? 496093
? 503907
? 498046
? 501954
? 499023
? 500977
? 499511
? 500489
? 499755
? 500245
? 499877
? 500123
? 499938
? 500062
? 499969
? 500031
? 499984
? 500016
? 499992
? 500008
? 499996
? 5...

result:

ok Correct position at 500001

Test #13:

score: 0
Accepted
time: 2ms
memory: 11880kb

input:

999999
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0

output:

? 249999
? 750000
? 374999
? 625000
? 437499
? 562500
? 468749
? 531250
? 484374
? 515625
? 492186
? 507813
? 496092
? 503907
? 498045
? 501954
? 499022
? 500977
? 499510
? 500489
? 499754
? 500245
? 499876
? 500123
? 499937
? 500062
? 499968
? 500031
? 499983
? 500016
? 499991
? 500008
? 499995
? 5...

result:

ok Correct position at 499999

Test #14:

score: 0
Accepted
time: 4ms
memory: 11444kb

input:

999998
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
2

output:

? 249999
? 749999
? 374999
? 624999
? 437499
? 562499
? 468749
? 531249
? 484374
? 515624
? 492186
? 507812
? 496092
? 503906
? 498045
? 501953
? 499022
? 500976
? 499510
? 500488
? 499754
? 500244
? 499876
? 500122
? 499937
? 500061
? 499968
? 500030
? 499983
? 500015
? 499991
? 500007
? 499995
? 5...

result:

ok Correct position at 500000

Test #15:

score: 0
Accepted
time: 1ms
memory: 13464kb

input:

999997
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0

output:

? 249999
? 749998
? 374998
? 624999
? 437498
? 562499
? 468748
? 531249
? 484373
? 515624
? 492185
? 507812
? 496091
? 503906
? 498044
? 501953
? 499021
? 500976
? 499509
? 500488
? 499753
? 500244
? 499875
? 500122
? 499936
? 500061
? 499967
? 500030
? 499982
? 500015
? 499990
? 500007
? 499994
? 5...

result:

ok Correct position at 499998

Test #16:

score: 0
Accepted
time: 0ms
memory: 11996kb

input:

999996
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
2

output:

? 249999
? 749997
? 374998
? 624998
? 437498
? 562498
? 468748
? 531248
? 484373
? 515623
? 492185
? 507811
? 496091
? 503905
? 498044
? 501952
? 499021
? 500975
? 499509
? 500487
? 499753
? 500243
? 499875
? 500121
? 499936
? 500060
? 499967
? 500029
? 499982
? 500014
? 499990
? 500006
? 499994
? 5...

result:

ok Correct position at 499999

Test #17:

score: 0
Accepted
time: 5ms
memory: 11192kb

input:

999995
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0

output:

? 249998
? 749997
? 374997
? 624998
? 437497
? 562498
? 468747
? 531248
? 484372
? 515623
? 492184
? 507811
? 496090
? 503905
? 498043
? 501952
? 499020
? 500975
? 499508
? 500487
? 499752
? 500243
? 499874
? 500121
? 499935
? 500060
? 499966
? 500029
? 499981
? 500014
? 499989
? 500006
? 499993
? 5...

result:

ok Correct position at 499997

Test #18:

score: 0
Accepted
time: 2ms
memory: 11440kb

input:

999994
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
2

output:

? 249998
? 749996
? 374997
? 624997
? 437497
? 562497
? 468747
? 531247
? 484372
? 515622
? 492184
? 507810
? 496090
? 503904
? 498043
? 501951
? 499020
? 500974
? 499508
? 500486
? 499752
? 500242
? 499874
? 500120
? 499935
? 500059
? 499966
? 500028
? 499981
? 500013
? 499989
? 500005
? 499993
? 5...

result:

ok Correct position at 499998

Test #19:

score: 0
Accepted
time: 1ms
memory: 12488kb

input:

999993
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0

output:

? 249998
? 749995
? 374997
? 624996
? 437496
? 562497
? 468746
? 531247
? 484371
? 515622
? 492183
? 507810
? 496089
? 503904
? 498042
? 501951
? 499019
? 500974
? 499507
? 500486
? 499751
? 500242
? 499873
? 500120
? 499934
? 500059
? 499965
? 500028
? 499980
? 500013
? 499988
? 500005
? 499992
? 5...

result:

ok Correct position at 499996

Test #20:

score: 0
Accepted
time: 1ms
memory: 12556kb

input:

999992
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
2

output:

? 249998
? 749994
? 374997
? 624995
? 437496
? 562496
? 468746
? 531246
? 484371
? 515621
? 492183
? 507809
? 496089
? 503903
? 498042
? 501950
? 499019
? 500973
? 499507
? 500485
? 499751
? 500241
? 499873
? 500119
? 499934
? 500058
? 499965
? 500027
? 499980
? 500012
? 499988
? 500004
? 499992
? 5...

result:

ok Correct position at 499997

Test #21:

score: 0
Accepted
time: 1ms
memory: 12504kb

input:

999991
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0

output:

? 249997
? 749994
? 374996
? 624995
? 437495
? 562496
? 468745
? 531246
? 484370
? 515621
? 492182
? 507809
? 496088
? 503903
? 498041
? 501950
? 499018
? 500973
? 499506
? 500485
? 499750
? 500241
? 499872
? 500119
? 499933
? 500058
? 499964
? 500027
? 499979
? 500012
? 499987
? 500004
? 499991
? 5...

result:

ok Correct position at 499995

Test #22:

score: -100
Wrong Answer
time: 3ms
memory: 11200kb

input:

1000000
1
2
3

output:

? 250000
? 750000
? 124999
? 0

result:

wrong answer Integer parameter [name=x] equals to 0, violates the range [1, 1000000]