QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#185621#6394. Turn on the LightUESTC_Guest_WiFi#TL 1ms3848kbC++14774b2023-09-22 13:19:122023-09-22 13:19:12

Judging History

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

  • [2023-09-22 13:19:12]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3848kb
  • [2023-09-22 13:19:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,x;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=max(20,n);++i)
    {
        printf("? %d\n",i);
        fflush(stdout);
        scanf("%d",&x);
        if (x!=i)
        {
            printf("! %d\n",i);
            fflush(stdout);
            return 0;
        }
    }
    int lastx=20;
    int l=21,r=n;
    while (l<=r)
    {
        int mid=(l+r)/2;
        printf("? %d\n",mid);
        fflush(stdout);
        scanf("%d",&x);
        if (x==lastx)
        {
            printf("! %d\n",mid);
            fflush(stdout);
            return 0;
        }
        if (x==lastx+1)
            l=mid+1;
        else
            r=mid-1;
        lastx=x;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

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: 1ms
memory: 3720kb

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

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

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: 1ms
memory: 3844kb

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: 1ms
memory: 3800kb

input:

5
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #8:

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

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: -100
Time 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...

output:

? 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...

result: