QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#594945#6394. Turn on the LightCarameowWA 1ms3728kbC++201.4kb2024-09-28 11:27:362024-09-28 11:27:37

Judging History

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

  • [2024-09-28 11:27:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2024-09-28 11:27:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;

void init() {
   cin >> n;
}

int ask(int x) {
   cout << "? " << x << "\n";
   cout << flush;
   int a; cin >> a;
   return a;
}

void fav(int ans) {
   cout << "! " << ans << "\n";
   exit(0);
}

void range(int f1, int l1, int f2, int l2, int diff, int out, bool type) {
   if(type) {
      int mid = f1 + l2 >> 1;
      int val = ask(mid);
      if(abs(out) == val) fav(mid);

      if(out > 0) {
         if(val > out) range(f1, 0, 0, mid - 1, 0, val, 1);
         else range(mid + 1, 0, 0, l2, 0, val, 1);
      }
      else if(out < 0) {
         if(val > - out) range(mid + 1, 0, 0, l2, 0, val, 1);
         else range(f1, 0, 0, mid - 1, 0, val, 1);
      }
      else range(f1, mid - 1, mid + 1, l2, val, out, 0);
   }
   else {
      if(l1 - f1 + 1 >= l2 - f2 + 1) {
         int mid = l1 + f1 >> 1;
         int val = ask(mid);
         if(diff == val) fav(mid);

         if(diff > val) range(mid + 1, 0, 0, l1, 0, out + val, 1);
         else if(diff < val) range(f1, mid - 1, f2, l2, val, out, 0);
      }
      else {
         int mid = l2 + f2 >> 1;
         int val = ask(mid);
         if(diff == val) fav(mid);

         if(diff > val) range(f2, 0, 0, mid - 1, 0, out - val, 1);
         else if(diff < val) range(f1, l1, mid + 1, l2, val, out, 0);
      }
   }
}

int main () {
   init();

   range(1, 0, 0, n, 0, 0, 1);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 2
? 1
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
5

output:

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

result:

ok Correct position at 10

Test #3:

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

input:

9
1
2
3
4
5
5

output:

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

result:

ok Correct position at 9

Test #4:

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

input:

8
1
2
3
4
5
5

output:

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

result:

ok Correct position at 8

Test #5:

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

input:

7
1
2
3
3

output:

? 4
? 2
? 6
? 1
! 1

result:

ok Correct position at 1

Test #6:

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

input:

6
1
2
3
3

output:

? 3
? 5
? 1
? 6
! 6

result:

ok Correct position at 6

Test #7:

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

input:

5
1
2
3
3

output:

? 3
? 1
? 4
? 5
! 5

result:

ok Correct position at 5

Test #8:

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

input:

4
1
2
3
3

output:

? 2
? 3
? 1
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 2
? 1
! 1

result:

ok Correct position at 1

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

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
37

output:

? 500000
? 750000
? 250000
? 875000
? 125000
? 937500
? 62500
? 968750
? 31250
? 984375
? 15625
? 992188
? 7812
? 996094
? 3906
? 998047
? 1953
? 999024
? 976
? 999512
? 488
? 999756
? 244
? 999878
? 122
? 999939
? 61
? 999970
? 30
? 999985
? 15
? 999993
? 7
? 999997
? 3
? 999999
? 1
? 1000000
! 100...

result:

ok Correct position at 1000000

Test #13:

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

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
37

output:

? 500000
? 250000
? 750000
? 125000
? 875000
? 62500
? 937500
? 31250
? 968750
? 15625
? 984375
? 7812
? 992187
? 996093
? 3906
? 998046
? 1953
? 999023
? 976
? 999511
? 488
? 999755
? 244
? 999877
? 122
? 999938
? 61
? 999969
? 30
? 999984
? 15
? 999992
? 7
? 999996
? 3
? 999998
? 1
? 999999
! 999999

result:

ok Correct position at 999999

Test #14:

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

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
37

output:

? 499999
? 749999
? 249999
? 874999
? 124999
? 937499
? 62499
? 968749
? 31249
? 984374
? 15624
? 992186
? 7812
? 996092
? 3906
? 998045
? 1953
? 999022
? 976
? 999510
? 488
? 999754
? 244
? 999876
? 122
? 999937
? 61
? 999968
? 30
? 999983
? 15
? 999991
? 7
? 999995
? 3
? 999997
? 1
? 999998
! 999998

result:

ok Correct position at 999998

Test #15:

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

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
37

output:

? 499999
? 249999
? 749998
? 874998
? 124999
? 937498
? 62499
? 968748
? 31249
? 984373
? 15624
? 992185
? 7812
? 996091
? 3906
? 998044
? 1953
? 999021
? 976
? 999509
? 488
? 999753
? 244
? 999875
? 122
? 999936
? 61
? 999967
? 30
? 999982
? 15
? 999990
? 7
? 999994
? 3
? 999996
? 1
? 999997
! 999997

result:

ok Correct position at 999997

Test #16:

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

input:

999996
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
37

output:

? 499998
? 749997
? 249999
? 874997
? 124999
? 937497
? 62499
? 968747
? 31249
? 984372
? 15624
? 992184
? 7812
? 996090
? 3906
? 998043
? 1953
? 999020
? 976
? 999508
? 488
? 999752
? 244
? 999874
? 122
? 999935
? 61
? 999966
? 30
? 999981
? 15
? 999989
? 7
? 999993
? 3
? 999995
? 1
? 999996
! 999996

result:

ok Correct position at 999996

Test #17:

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

input:

999995
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
37

output:

? 499998
? 249999
? 749997
? 124999
? 874996
? 937496
? 62499
? 968746
? 31249
? 984371
? 15624
? 992183
? 7812
? 996089
? 3906
? 998042
? 1953
? 999019
? 976
? 999507
? 488
? 999751
? 244
? 999873
? 122
? 999934
? 61
? 999965
? 30
? 999980
? 15
? 999988
? 7
? 999992
? 3
? 999994
? 1
? 999995
! 999995

result:

ok Correct position at 999995

Test #18:

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

input:

999994
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
37

output:

? 499997
? 749996
? 249998
? 874995
? 124999
? 937495
? 62499
? 968745
? 31249
? 984370
? 15624
? 992182
? 7812
? 996088
? 3906
? 998041
? 1953
? 999018
? 976
? 999506
? 488
? 999750
? 244
? 999872
? 122
? 999933
? 61
? 999964
? 30
? 999979
? 15
? 999987
? 7
? 999991
? 3
? 999993
? 1
? 999994
! 999994

result:

ok Correct position at 999994

Test #19:

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

input:

999993
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
37

output:

? 499997
? 249998
? 749995
? 874994
? 124999
? 937494
? 62499
? 968744
? 31249
? 984369
? 15624
? 992181
? 7812
? 996087
? 3906
? 998040
? 1953
? 999017
? 976
? 999505
? 488
? 999749
? 244
? 999871
? 122
? 999932
? 61
? 999963
? 30
? 999978
? 15
? 999986
? 7
? 999990
? 3
? 999992
? 1
? 999993
! 999993

result:

ok Correct position at 999993

Test #20:

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

input:

999992
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
37

output:

? 499996
? 749994
? 249998
? 874993
? 124999
? 937493
? 62499
? 968743
? 31249
? 984368
? 15624
? 992180
? 7812
? 996086
? 3906
? 998039
? 1953
? 999016
? 976
? 999504
? 488
? 999748
? 244
? 999870
? 122
? 999931
? 61
? 999962
? 30
? 999977
? 15
? 999985
? 7
? 999989
? 3
? 999991
? 1
? 999992
! 999992

result:

ok Correct position at 999992

Test #21:

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

input:

999991
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
37

output:

? 499996
? 249998
? 749994
? 124999
? 874993
? 62499
? 937492
? 968742
? 31249
? 984367
? 15624
? 992179
? 7812
? 996085
? 3906
? 998038
? 1953
? 999015
? 976
? 999503
? 488
? 999747
? 244
? 999869
? 122
? 999930
? 61
? 999961
? 30
? 999976
? 15
? 999984
? 7
? 999988
? 3
? 999990
? 1
? 999991
! 999991

result:

ok Correct position at 999991

Test #22:

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

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
27
28
27
26
26

output:

? 500000
? 750000
? 250000
? 875000
? 125000
? 937500
? 62500
? 968750
? 31250
? 984375
? 15625
? 992188
? 7812
? 996094
? 3906
? 998047
? 1953
? 999024
? 976
? 999512
? 488
? 999756
? 244
? 999878
? 122
? 999939
? 61
? 999970
? 30
? 45
? 37
? 41
? 43
! 43

result:

ok Correct position at 43

Test #23:

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

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
27
26
27
26
26

output:

? 500000
? 250000
? 750000
? 125000
? 875000
? 62500
? 937500
? 31250
? 968750
? 15625
? 984375
? 7812
? 992187
? 996093
? 3906
? 998046
? 1953
? 999023
? 976
? 999511
? 488
? 999755
? 244
? 999877
? 122
? 999938
? 61
? 999969
? 30
? 45
? 53
? 49
? 51
! 51

result:

ok Correct position at 51

Test #24:

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

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
27
26
27
26
26

output:

? 499999
? 749999
? 249999
? 874999
? 124999
? 937499
? 62499
? 968749
? 31249
? 984374
? 15624
? 992186
? 7812
? 996092
? 3906
? 998045
? 1953
? 999022
? 976
? 999510
? 488
? 999754
? 244
? 999876
? 122
? 999937
? 61
? 999968
? 30
? 45
? 53
? 49
? 51
! 51

result:

ok Correct position at 51

Test #25:

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

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
27
26
27
26
26

output:

? 499999
? 249999
? 749998
? 874998
? 124999
? 937498
? 62499
? 968748
? 31249
? 984373
? 15624
? 992185
? 7812
? 996091
? 3906
? 998044
? 1953
? 999021
? 976
? 999509
? 488
? 999753
? 244
? 999875
? 122
? 999936
? 61
? 999967
? 30
? 45
? 53
? 49
? 51
! 51

result:

ok Correct position at 51

Test #26:

score: -100
Wrong Answer
time: 1ms
memory: 3584kb

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
22
21
20
19
18
17
16
15
15

output:

? 500000
? 750000
? 250000
? 875000
? 125000
? 937500
? 62500
? 968750
? 31250
? 984375
? 15625
? 992188
? 7812
? 996094
? 3906
? 998047
? 1953
? 999024
? 976
? 999512
? 488
? 999756
? 244
? 999878
? 999817
? 999786
? 999801
? 999809
? 999813
? 999815
? 999816
? 999816
! 999816

result:

wrong answer Wrong favorite light!