QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#613397#6394. Turn on the LightliaoyingyuML 1ms3688kbC++17617b2024-10-05 13:59:372024-10-05 14:02:13

Judging History

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

  • [2024-10-05 14:02:13]
  • 评测
  • 测评结果:ML
  • 用时:1ms
  • 内存:3688kb
  • [2024-10-05 13:59:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int s = 0;
int pre = 0;
void beizeng(int start, int end) {
	int now = 1;
	int shuru;
	while (1) {
		if (s+now > end) {
			s += now / 2;
			beizeng(now / 2+1, end);
			return;
		}
		cout << '?' << ' ' << s+now << endl;
		cin >> shuru;
		if (shuru == pre) {
			cout << '!' << ' ' << s+now << endl;
			return;
		}
		else if (shuru > pre) {
			pre = shuru;
			now *= 2;
		}
		else {
			s += now / 2;
			pre = shuru;
			beizeng(now / 2+1, now-1);
			return;
		}
	}
}
signed main() {
	int n;
	cin >> n;
	beizeng(1, n);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
2
3
3

output:

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

result:

ok Correct position at 6

Test #3:

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

input:

9
1
2
3
2
3
3

output:

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

result:

ok Correct position at 6

Test #4:

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

input:

8
1
2
3
2
3
3

output:

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

result:

ok Correct position at 6

Test #5:

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

input:

7
1
2
3
4
5
5

output:

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

result:

ok Correct position at 7

Test #6:

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

input:

6
1
2
3
3

output:

? 1
? 2
? 4
? 5
! 5

result:

ok Correct position at 5

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 2
? 4
? 5
! 5

result:

ok Correct position at 5

Test #8:

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

input:

4
1
2
2

output:

? 1
? 2
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: -100
Memory Limit Exceeded

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
72

output:

? 1
? 2
? 4
? 8
? 16
? 32
? 64
? 128
? 256
? 512
? 1024
? 2048
? 4096
? 8192
? 16384
? 32768
? 65536
? 131072
? 262144
? 524288
? 524289
? 524290
? 524292
? 524296
? 524304
? 524320
? 524352
? 524416
? 524544
? 524800
? 525312
? 526336
? 528384
? 532480
? 540672
? 557056
? 589824
? 655360
? 786432
?...

result: