QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470421#6394. Turn on the LightUESTC_OldEastWest#AC ✓2ms7060kbC++17999b2024-07-10 13:12:442024-07-10 13:12:46

Judging History

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

  • [2024-07-10 13:12:46]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:7060kb
  • [2024-07-10 13:12:44]
  • 提交

answer

#include <bits/stdc++.h>
using ll = long long;

void charming() {
  int n; std::cin >> n;
  std::vector<int> vis(n + 1, -1);
  
  auto send = [&](int x) -> int {
    if (vis[x] != -1) return vis[x];
    std::cout << "? " << x << std::endl;
    std::cout.flush();
    int ret; std::cin >> ret;
    return vis[x] = ret;
  };

  auto answer = [&](int x) -> void {
    std::cout << "! " << x << std::endl;
    std::cout.flush();
  };

  int l = 1, r = n, k = 1, st = 1, lst = 0;
  while (l <= r) {
    int mid = l + r >> 1;
    int ret1 = send(mid);
    if (ret1 == lst) {k = mid; break;}
    while (vis[st] != -1) ++st; 
    int ret2 = send(st++);
    if (ret2 == ret1) {k = st - 1; break;}
    else if (ret1 - lst == ret2 - ret1) l = mid + 1;
    else r = mid - 1;
    l = std::max(l, st);
    lst = ret2;
  }

  answer(k);
}

signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  charming();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 2
? 1
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
6
6

output:

? 5
? 1
? 8
? 2
? 9
? 3
? 10
! 10

result:

ok Correct position at 10

Test #3:

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

input:

9
1
2
3
4
5
6
6

output:

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

result:

ok Correct position at 9

Test #4:

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

input:

8
1
2
3
4
5
6
6

output:

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

result:

ok Correct position at 8

Test #5:

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

input:

7
1
2
3
4
4

output:

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

result:

ok Correct position at 7

Test #6:

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

input:

6
1
2
3
4
4

output:

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

result:

ok Correct position at 6

Test #7:

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

input:

5
1
2
3
4
4

output:

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

result:

ok Correct position at 5

Test #8:

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

input:

4
1
2
3
3

output:

? 2
? 1
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 2
? 1
! 1

result:

ok Correct position at 1

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

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
31
32
31
32
33
34
34

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 968750
? 5
? 984375
? 6
? 992188
? 7
? 996094
? 8
? 998047
? 9
? 999024
? 10
? 999512
? 11
? 999756
? 12
? 999878
? 13
? 999939
? 14
? 999970
? 15
? 999985
? 16
? 999993
? 17
? 999989
? 18
? 999987
? 19
? 999988
! 999988

result:

ok Correct position at 999988

Test #13:

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

input:

999999
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 906250
? 5
? 890625
? 6
? 882812
? 7
? 886718
? 8
? 888671
? 9
? 889648
? 10
? 890136
? 11
? 890380
? 12
? 890502
? 13
? 890563
? 14
? 890594
? 15
? 890609
? 16
? 890617
? 17
? 890613
? 18
? 890611
? 19
? 890612
! 890612

result:

ok Correct position at 890612

Test #14:

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

input:

999998
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 499999
? 1
? 749999
? 2
? 874999
? 3
? 937499
? 4
? 906249
? 5
? 890624
? 6
? 882811
? 7
? 886717
? 8
? 888670
? 9
? 889647
? 10
? 890135
? 11
? 890379
? 12
? 890501
? 13
? 890562
? 14
? 890593
? 15
? 890608
? 16
? 890616
? 17
? 890612
? 18
? 890610
? 19
? 890611
! 890611

result:

ok Correct position at 890611

Test #15:

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

input:

999997
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 499999
? 1
? 749998
? 2
? 874998
? 3
? 937498
? 4
? 906248
? 5
? 890623
? 6
? 882810
? 7
? 886716
? 8
? 888669
? 9
? 889646
? 10
? 890134
? 11
? 890378
? 12
? 890500
? 13
? 890561
? 14
? 890592
? 15
? 890607
? 16
? 890615
? 17
? 890611
? 18
? 890609
? 19
? 890610
! 890610

result:

ok Correct position at 890610

Test #16:

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

input:

999996
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 499998
? 1
? 749997
? 2
? 874997
? 3
? 937497
? 4
? 906247
? 5
? 890622
? 6
? 882809
? 7
? 886715
? 8
? 888668
? 9
? 889645
? 10
? 890133
? 11
? 890377
? 12
? 890499
? 13
? 890560
? 14
? 890591
? 15
? 890606
? 16
? 890614
? 17
? 890610
? 18
? 890608
? 19
? 890609
! 890609

result:

ok Correct position at 890609

Test #17:

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

input:

999995
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 499998
? 1
? 749997
? 2
? 874996
? 3
? 937496
? 4
? 906246
? 5
? 890621
? 6
? 882808
? 7
? 886714
? 8
? 888667
? 9
? 889644
? 10
? 890132
? 11
? 890376
? 12
? 890498
? 13
? 890559
? 14
? 890590
? 15
? 890605
? 16
? 890613
? 17
? 890609
? 18
? 890607
? 19
? 890608
! 890608

result:

ok Correct position at 890608

Test #18:

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

input:

999994
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 499997
? 1
? 749996
? 2
? 874995
? 3
? 937495
? 4
? 906245
? 5
? 890620
? 6
? 882807
? 7
? 886713
? 8
? 888666
? 9
? 889643
? 10
? 890131
? 11
? 890375
? 12
? 890497
? 13
? 890558
? 14
? 890589
? 15
? 890604
? 16
? 890612
? 17
? 890608
? 18
? 890606
? 19
? 890607
! 890607

result:

ok Correct position at 890607

Test #19:

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

input:

999993
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 499997
? 1
? 749995
? 2
? 874994
? 3
? 937494
? 4
? 906244
? 5
? 890619
? 6
? 882806
? 7
? 886712
? 8
? 888665
? 9
? 889642
? 10
? 890130
? 11
? 890374
? 12
? 890496
? 13
? 890557
? 14
? 890588
? 15
? 890603
? 16
? 890611
? 17
? 890607
? 18
? 890605
? 19
? 890606
! 890606

result:

ok Correct position at 890606

Test #20:

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

input:

999992
1
2
3
4
5
6
5
6
5
6
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
25
26
25
26
27
28
28

output:

? 499996
? 1
? 749994
? 2
? 874993
? 3
? 937493
? 4
? 906243
? 5
? 890618
? 6
? 882805
? 7
? 886711
? 8
? 888664
? 9
? 889641
? 10
? 890129
? 11
? 890373
? 12
? 890495
? 13
? 890556
? 14
? 890587
? 15
? 890602
? 16
? 890610
? 17
? 890606
? 18
? 890604
? 19
? 890605
! 890605

result:

ok Correct position at 890605

Test #21:

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

input:

999991
1
2
3
4
5
6
7
8
7
8
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
27
28
27
28
29
30
30

output:

? 499996
? 1
? 749994
? 2
? 874993
? 3
? 937492
? 4
? 968742
? 5
? 953117
? 6
? 945304
? 7
? 949210
? 8
? 951163
? 9
? 952140
? 10
? 952628
? 11
? 952872
? 12
? 952994
? 13
? 953055
? 14
? 953086
? 15
? 953101
? 16
? 953109
? 17
? 953105
? 18
? 953103
? 19
? 953104
! 953104

result:

ok Correct position at 953104

Test #22:

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

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
0

output:

? 500000
? 1
? 250000
? 2
? 125001
? 3
? 62502
? 4
? 31253
? 5
? 15629
? 6
? 7817
? 7
? 3912
? 8
? 1960
? 9
? 984
? 10
? 497
? 11
? 254
? 12
? 133
? 13
? 73
? 14
? 43
! 43

result:

ok Correct position at 43

Test #23:

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

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
2
1
2
3
4
3
4
3
4
4

output:

? 500000
? 1
? 250000
? 2
? 125001
? 3
? 62502
? 4
? 31253
? 5
? 15629
? 6
? 7817
? 7
? 3912
? 8
? 1960
? 9
? 984
? 10
? 497
? 11
? 254
? 12
? 133
? 13
? 73
? 14
? 43
? 15
? 58
? 16
? 50
? 17
? 54
? 18
? 52
? 19
? 51
! 51

result:

ok Correct position at 51

Test #24:

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

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
2
1
2
3
4
3
4
3
4
4

output:

? 499999
? 1
? 250000
? 2
? 125001
? 3
? 62502
? 4
? 31253
? 5
? 15629
? 6
? 7817
? 7
? 3912
? 8
? 1960
? 9
? 984
? 10
? 497
? 11
? 254
? 12
? 133
? 13
? 73
? 14
? 43
? 15
? 58
? 16
? 50
? 17
? 54
? 18
? 52
? 19
? 51
! 51

result:

ok Correct position at 51

Test #25:

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

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
2
1
2
3
4
3
4
3
4
4

output:

? 499999
? 1
? 250000
? 2
? 125001
? 3
? 62502
? 4
? 31253
? 5
? 15629
? 6
? 7817
? 7
? 3912
? 8
? 1960
? 9
? 984
? 10
? 497
? 11
? 254
? 12
? 133
? 13
? 73
? 14
? 43
? 15
? 58
? 16
? 50
? 17
? 54
? 18
? 52
? 19
? 51
! 51

result:

ok Correct position at 51

Test #26:

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

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
23
24
23
24
23
24
25
26
27
28
27
28
29
30
30

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 968750
? 5
? 984375
? 6
? 992188
? 7
? 996094
? 8
? 998047
? 9
? 999024
? 10
? 999512
? 11
? 999756
? 12
? 999878
? 13
? 999817
? 14
? 999786
? 15
? 999771
? 16
? 999778
? 17
? 999782
? 18
? 999780
? 19
? 999781
! 999781

result:

ok Correct position at 999781

Test #27:

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

input:

999999
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
29
30
31
32
32

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 968750
? 5
? 984375
? 6
? 992187
? 7
? 996093
? 8
? 998046
? 9
? 999023
? 10
? 999511
? 11
? 999755
? 12
? 999877
? 13
? 999938
? 14
? 999969
? 15
? 999984
? 16
? 999976
? 17
? 999980
! 999980

result:

ok Correct position at 999980

Test #28:

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

input:

999998
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
29
30
31
32
32

output:

? 499999
? 1
? 749999
? 2
? 874999
? 3
? 937499
? 4
? 968749
? 5
? 984374
? 6
? 992186
? 7
? 996092
? 8
? 998045
? 9
? 999022
? 10
? 999510
? 11
? 999754
? 12
? 999876
? 13
? 999937
? 14
? 999968
? 15
? 999983
? 16
? 999975
? 17
? 999979
! 999979

result:

ok Correct position at 999979

Test #29:

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

input:

999997
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
29
30
31
32
32

output:

? 499999
? 1
? 749998
? 2
? 874998
? 3
? 937498
? 4
? 968748
? 5
? 984373
? 6
? 992185
? 7
? 996091
? 8
? 998044
? 9
? 999021
? 10
? 999509
? 11
? 999753
? 12
? 999875
? 13
? 999936
? 14
? 999967
? 15
? 999982
? 16
? 999974
? 17
? 999978
! 999978

result:

ok Correct position at 999978

Test #30:

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

input:

1000000
1
0
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
25
26
25
26
27
28
27
28
28

output:

? 500000
? 1
? 250000
? 2
? 375000
? 3
? 437500
? 4
? 468750
? 5
? 484375
? 6
? 492187
? 7
? 496093
? 8
? 498046
? 9
? 499023
? 10
? 499511
? 11
? 499755
? 12
? 499877
? 13
? 499938
? 14
? 499969
? 15
? 499953
? 16
? 499945
? 17
? 499949
? 18
? 499947
! 499947

result:

ok Correct position at 499947

Test #31:

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

input:

999999
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
3
4
3
4
3
4
5
6
5
6
6

output:

? 500000
? 1
? 750000
? 2
? 625000
? 3
? 562500
? 4
? 531250
? 5
? 515625
? 6
? 507812
? 7
? 503906
? 8
? 501953
? 9
? 500976
? 10
? 500488
? 11
? 500244
? 12
? 500122
? 13
? 500061
? 14
? 500091
? 15
? 500076
? 16
? 500068
? 17
? 500072
? 18
? 500070
! 500070

result:

ok Correct position at 500070

Test #32:

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

input:

999998
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
3
4
3
4
5
6
5
6
5
6
6

output:

? 499999
? 1
? 749999
? 2
? 624999
? 3
? 562499
? 4
? 531249
? 5
? 515624
? 6
? 507811
? 7
? 503905
? 8
? 501952
? 9
? 500975
? 10
? 500487
? 11
? 500243
? 12
? 500121
? 13
? 500060
? 14
? 500090
? 15
? 500075
? 16
? 500082
? 17
? 500078
? 18
? 500076
! 500076

result:

ok Correct position at 500076

Test #33:

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

input:

999997
1
0
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
25
26
27
28
29
30
31
32
31
32
32

output:

? 499999
? 1
? 250000
? 2
? 374999
? 3
? 437499
? 4
? 468749
? 5
? 484374
? 6
? 492186
? 7
? 496092
? 8
? 498045
? 9
? 499022
? 10
? 499510
? 11
? 499754
? 12
? 499876
? 13
? 499937
? 14
? 499968
? 15
? 499952
? 16
? 499960
? 17
? 499964
? 18
? 499966
? 19
? 499965
! 499965

result:

ok Correct position at 499965

Test #34:

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

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
11
12
13
14
15
16
15
16
17
18
19
20
21
22
23
24
23
24
25
26
25
26
25
26
25
26
26

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 968750
? 5
? 984375
? 6
? 992188
? 7
? 988281
? 8
? 990234
? 9
? 991211
? 10
? 990722
? 11
? 990966
? 12
? 991088
? 13
? 991149
? 14
? 991180
? 15
? 991164
? 16
? 991172
? 17
? 991168
? 18
? 991166
? 19
? 991165
! 991165

result:

ok Correct position at 991165

Test #35:

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

input:

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

output:

? 500000
? 1
? 750000
? 2
? 625000
? 3
? 562500
? 4
? 531250
? 5
? 515625
? 6
? 507812
? 7
? 511718
? 8
? 513671
? 9
? 514648
? 10
? 514159
? 11
? 514403
? 12
? 514525
? 13
? 514586
? 14
? 514617
? 15
? 514601
? 16
? 514609
? 17
? 514605
? 18
? 514603
? 19
? 514602
! 514602

result:

ok Correct position at 514602

Test #36:

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

input:

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

output:

? 499999
? 1
? 749999
? 2
? 624999
? 3
? 562499
? 4
? 531249
? 5
? 515624
? 6
? 507811
? 7
? 511717
? 8
? 513670
? 9
? 514647
? 10
? 514158
? 11
? 514402
? 12
? 514524
? 13
? 514585
? 14
? 514616
? 15
? 514600
? 16
? 514608
? 17
? 514604
? 18
? 514602
? 19
? 514601
! 514601

result:

ok Correct position at 514601

Test #37:

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

input:

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

output:

? 499999
? 1
? 749998
? 2
? 874998
? 3
? 812498
? 4
? 781248
? 5
? 765623
? 6
? 757810
? 7
? 761716
? 8
? 763669
? 9
? 764646
? 10
? 764157
? 11
? 764401
? 12
? 764523
? 13
? 764584
? 14
? 764615
? 15
? 764599
? 16
? 764607
? 17
? 764603
? 18
? 764601
? 19
? 764600
! 764600

result:

ok Correct position at 764600

Test #38:

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

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
38

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 968750
? 5
? 984375
? 6
? 992188
? 7
? 996094
? 8
? 998047
? 9
? 999024
? 10
? 999512
? 11
? 999756
? 12
? 999878
? 13
? 999939
? 14
? 999970
? 15
? 999985
? 16
? 999993
? 17
? 999997
? 18
? 999999
? 19
? 1000000
! 1000000

result:

ok Correct position at 1000000

Test #39:

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

input:

999999
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
38

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 968750
? 5
? 984375
? 6
? 992187
? 7
? 996093
? 8
? 998046
? 9
? 999023
? 10
? 999511
? 11
? 999755
? 12
? 999877
? 13
? 999938
? 14
? 999969
? 15
? 999984
? 16
? 999992
? 17
? 999996
? 18
? 999998
? 19
? 999999
! 999999

result:

ok Correct position at 999999

Test #40:

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

input:

999998
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
38

output:

? 499999
? 1
? 749999
? 2
? 874999
? 3
? 937499
? 4
? 968749
? 5
? 984374
? 6
? 992186
? 7
? 996092
? 8
? 998045
? 9
? 999022
? 10
? 999510
? 11
? 999754
? 12
? 999876
? 13
? 999937
? 14
? 999968
? 15
? 999983
? 16
? 999991
? 17
? 999995
? 18
? 999997
? 19
? 999998
! 999998

result:

ok Correct position at 999998

Test #41:

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

input:

999997
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
38

output:

? 499999
? 1
? 749998
? 2
? 874998
? 3
? 937498
? 4
? 968748
? 5
? 984373
? 6
? 992185
? 7
? 996091
? 8
? 998044
? 9
? 999021
? 10
? 999509
? 11
? 999753
? 12
? 999875
? 13
? 999936
? 14
? 999967
? 15
? 999982
? 16
? 999990
? 17
? 999994
? 18
? 999996
? 19
? 999997
! 999997

result:

ok Correct position at 999997

Test #42:

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

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
38

output:

? 500000
? 1
? 750000
? 2
? 875000
? 3
? 937500
? 4
? 968750
? 5
? 984375
? 6
? 992188
? 7
? 996094
? 8
? 998047
? 9
? 999024
? 10
? 999512
? 11
? 999756
? 12
? 999878
? 13
? 999939
? 14
? 999970
? 15
? 999985
? 16
? 999993
? 17
? 999997
? 18
? 999999
? 19
? 1000000
! 1000000

result:

ok Correct position at 1000000

Test #43:

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

input:

1000000
1
1

output:

? 500000
? 1
! 1

result:

ok Correct position at 1