QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417522#6394. Turn on the LightLCJWA 1ms3640kbC++14650b2024-05-22 19:31:262024-05-22 19:31:27

Judging History

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

  • [2024-05-22 19:31:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-05-22 19:31:26]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,m,k,q,ans;
int ask(int x){
	cout<<"? "<<x<<endl;
	//cout.flush();
	int res;
	cin>>res;
	return res;
}
void solve(){
	cin>>n;
	k=0;
	int l=11,r=n;
	for(int i=1;i<=10;i++){
		int kk=ask(i);
		if(k==kk){
			cout<<"! "<<i<<endl;
			return;
		}
		k=kk;
	}
	ans=10;
	while(l<=r){
		int mid=(l+r)/2;
		ans=ask(mid);
		if(ans==k){
			cout<<"! "<<mid<<endl;
			return;
		}
		if(k<ans){
			k=ans;
			l=mid+1;
		}
		else{
			k=ans;
			r=mid-1;
		}
	}
	
}
signed main(){
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3620kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
6
7
8
8

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
! 9

result:

ok Correct position at 9

Test #3:

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

input:

9
1
2
3
4
5
6
7
7

output:

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

result:

ok Correct position at 8

Test #4:

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

input:

8
1
2
3
4
5
6
6

output:

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

result:

ok Correct position at 7

Test #5:

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

input:

7
1
2
3
4
5
5

output:

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

result:

ok Correct position at 6

Test #6:

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

input:

6
1
2
3
4
5
5

output:

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

result:

ok Correct position at 6

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #8:

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

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: 3508kb

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
10
11
12
11
12
13
14
15
14
15
16
17
18
17
18
19
20
19
19

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500005
? 750003
? 625004
? 687503
? 718753
? 703128
? 710940
? 714846
? 716799
? 717776
? 717287
? 717531
? 717653
? 717714
? 717745
? 717729
? 717737
? 717741
? 717743
? 717742
! 717742

result:

ok Correct position at 717742

Test #13:

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

input:

999999
1
2
3
4
5
6
7
8
9
10
9
10
11
12
11
12
13
14
15
14
15
16
17
18
17
18
19
20
19
19

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500005
? 250007
? 375006
? 437505
? 468755
? 453130
? 460942
? 464848
? 466801
? 467778
? 467289
? 467533
? 467655
? 467716
? 467747
? 467731
? 467739
? 467743
? 467745
? 467744
! 467744

result:

ok Correct position at 467744

Test #14:

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

input:

999998
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
14
15
16
17
16
17
18
19
20
19
20
21
22
21
21

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500004
? 750001
? 875000
? 937499
? 968749
? 953124
? 960936
? 964842
? 966795
? 967772
? 967283
? 967527
? 967649
? 967710
? 967741
? 967725
? 967733
? 967737
? 967739
? 967738
! 967738

result:

ok Correct position at 967738

Test #15:

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

input:

999997
1
2
3
4
5
6
7
8
9
10
9
8
9
10
9
10
11
12
13
12
13
14
15
16
15
16
17
18
17
17

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500004
? 250007
? 125008
? 187507
? 218757
? 203132
? 210944
? 214850
? 216803
? 217780
? 217291
? 217535
? 217657
? 217718
? 217749
? 217733
? 217741
? 217745
? 217747
? 217746
! 217746

result:

ok Correct position at 217746

Test #16:

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

input:

999996
1
2
3
4
5
6
7
8
9
10
11
10
11
12
11
12
13
14
15
14
15
16
17
18
17
18
19
20
19
19

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500003
? 750000
? 625001
? 687500
? 718750
? 703125
? 710937
? 714843
? 716796
? 717773
? 717284
? 717528
? 717650
? 717711
? 717742
? 717726
? 717734
? 717738
? 717740
? 717739
! 717739

result:

ok Correct position at 717739

Test #17:

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

input:

999995
1
2
3
4
5
6
7
8
9
10
9
10
11
12
11
12
13
14
15
14
15
16
17
18
17
18
19
20
19
19

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500003
? 250006
? 375004
? 437503
? 468753
? 453128
? 460940
? 464846
? 466799
? 467776
? 467287
? 467531
? 467653
? 467714
? 467745
? 467729
? 467737
? 467741
? 467743
? 467742
! 467742

result:

ok Correct position at 467742

Test #18:

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

input:

999994
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
14
15
16
17
16
17
18
19
20
19
20
21
22
21
21

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500002
? 749998
? 874996
? 937495
? 968745
? 953120
? 960932
? 964838
? 966791
? 967768
? 967279
? 967523
? 967645
? 967706
? 967737
? 967721
? 967729
? 967733
? 967735
? 967734
! 967734

result:

ok Correct position at 967734

Test #19:

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

input:

999993
1
2
3
4
5
6
7
8
9
10
9
8
9
10
11
12
13
14
15
14
15
16
17
18
17
18
19
20
19
19

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500002
? 250006
? 125008
? 187507
? 218756
? 234381
? 242193
? 246099
? 248052
? 249029
? 248540
? 248784
? 248906
? 248967
? 248998
? 248982
? 248990
? 248994
? 248996
? 248995
! 248995

result:

ok Correct position at 248995

Test #20:

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

input:

999992
1
2
3
4
5
6
7
8
9
10
11
10
11
12
13
14
15
16
17
16
17
18
19
20
19
20
21
22
21
21

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500001
? 749997
? 624999
? 687498
? 718747
? 734372
? 742184
? 746090
? 748043
? 749020
? 748531
? 748775
? 748897
? 748958
? 748989
? 748973
? 748981
? 748985
? 748987
? 748986
! 748986

result:

ok Correct position at 748986

Test #21:

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

input:

999991
1
2
3
4
5
6
7
8
9
10
9
10
11
12
13
14
15
16
17
16
17
18
19
20
19
20
21
22
21
21

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500001
? 250005
? 375003
? 437502
? 468751
? 484376
? 492188
? 496094
? 498047
? 499024
? 498535
? 498779
? 498901
? 498962
? 498993
? 498977
? 498985
? 498989
? 498991
? 498990
! 498990

result:

ok Correct position at 498990

Test #22:

score: -100
Wrong Answer
time: 0ms
memory: 3516kb

input:

1000000
1
2
3
4
5
6
7
8
9
10
9
8
7
6
5
4
3
2
1
0
1
2
3
4
5
6
7
8
9
10

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500005
? 250007
? 125008
? 62509
? 31259
? 15634
? 7822
? 3916
? 1963
? 986
? 498
? 742
? 864
? 925
? 955
? 970
? 978
? 982
? 984
? 985

result:

wrong answer format  Unexpected end of file - token expected