QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#110061#6394. Turn on the Lightjujimeizuo#AC ✓5ms3616kbC++14922b2023-05-31 13:30:032023-05-31 13:30:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-31 13:30:07]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:3616kb
  • [2023-05-31 13:30:03]
  • 提交

answer

/**
 *    author:  jujimeizuo
 *    created: 2023-05-31 13:14:54
**/
#include "bits/stdc++.h"

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int query(int x) {
	std::cout << "? " << x << std::endl;
	int y;
	std::cin >> y;
	return y;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    int l = 1, r = n;
    int ans = 0;
    while (l < r) {
    	int mid = (l + r + 1) / 2;
    	if (ans == 0) {
    		int x = query(l);
    		if (x == 0) {
    			break;
    		} else {
    			ans = x;
    			l = l + 1;
    		}
    	} else {
    		int x = query(mid);
    		if (x == ans - 1) {
    			r = mid - 1;
    		} else if (x == ans + 1) {
    			l = mid + 1;
    		} else {
    			l = r = mid;
    		}
    		ans = x;
    	}
    }

    std::cout << "! " << l << std::endl;

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3604kb

input:

3
1
1

output:

? 1
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
0
1
0

output:

? 1
? 6
? 2
? 4
! 3

result:

ok Correct position at 3

Test #3:

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

input:

9
1
0
1
0

output:

? 1
? 6
? 2
? 4
! 3

result:

ok Correct position at 3

Test #4:

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

input:

8
1
0
1
0

output:

? 1
? 5
? 2
? 4
! 3

result:

ok Correct position at 3

Test #5:

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

input:

7
1
0
1
0

output:

? 1
? 5
? 2
? 4
! 3

result:

ok Correct position at 3

Test #6:

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

input:

6
1
0
1

output:

? 1
? 4
? 2
! 3

result:

ok Correct position at 3

Test #7:

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

input:

5
1
0
1

output:

? 1
? 4
? 2
! 3

result:

ok Correct position at 3

Test #8:

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

input:

4
1
1

output:

? 1
? 3
! 3

result:

ok Correct position at 3

Test #9:

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

input:

3
1
0

output:

? 1
? 3
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1

output:

? 1
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1

output:

! 1

result:

ok Correct position at 1

Test #12:

score: 0
Accepted
time: 3ms
memory: 3380kb

input:

1000000
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
2
3
2
3
2

output:

? 1
? 500001
? 2
? 250002
? 3
? 125003
? 4
? 62504
? 5
? 31255
? 6
? 15631
? 7
? 7819
? 11725
? 9772
? 10749
? 10261
? 9773
? 10017
? 9774
? 9896
? 9775
? 9836
? 9776
? 9806
? 9821
? 9829
? 9825
? 9827
! 9826

result:

ok Correct position at 9826

Test #13:

score: 0
Accepted
time: 4ms
memory: 3424kb

input:

999999
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
2
3
2
3
2

output:

? 1
? 500001
? 2
? 250002
? 3
? 125003
? 4
? 62504
? 5
? 31255
? 6
? 15631
? 7
? 7819
? 11725
? 9772
? 10749
? 10261
? 9773
? 10017
? 9774
? 9896
? 9775
? 9836
? 9776
? 9806
? 9821
? 9829
? 9825
? 9827
! 9826

result:

ok Correct position at 9826

Test #14:

score: 0
Accepted
time: 4ms
memory: 3368kb

input:

999998
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 500000
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #15:

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

input:

999997
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 500000
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #16:

score: 0
Accepted
time: 4ms
memory: 3412kb

input:

999996
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 499999
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #17:

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

input:

999995
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 499999
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #18:

score: 0
Accepted
time: 3ms
memory: 3564kb

input:

999994
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 499998
? 2
? 250000
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #19:

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

input:

999993
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 499998
? 2
? 250000
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #20:

score: 0
Accepted
time: 4ms
memory: 3436kb

input:

999992
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 499997
? 2
? 250000
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #21:

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

input:

999991
1
0
1
0
1
0
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
2
1
2

output:

? 1
? 499997
? 2
? 250000
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 46879
? 39067
? 31255
? 35161
? 37114
? 36138
? 35162
? 35650
? 35894
? 36016
? 35955
? 35925
? 35895
? 35910
? 35896
? 35903
? 35907
? 35905
! 35906

result:

ok Correct position at 35906

Test #22:

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

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

output:

? 1
? 500001
? 2
? 250002
? 3
? 125003
? 4
? 62504
? 5
? 31255
? 6
? 15631
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 16
? 31
? 38
? 42
? 44
! 43

result:

ok Correct position at 43

Test #23:

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

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
0
1
2
1

output:

? 1
? 500001
? 2
? 250002
? 3
? 125003
? 4
? 62504
? 5
? 31255
? 6
? 15631
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 60
? 53
? 46
? 50
? 52
! 51

result:

ok Correct position at 51

Test #24:

score: 0
Accepted
time: 3ms
memory: 3432kb

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
0
1
2
1

output:

? 1
? 500000
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 6
? 15630
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 60
? 53
? 46
? 50
? 52
! 51

result:

ok Correct position at 51

Test #25:

score: 0
Accepted
time: 3ms
memory: 3336kb

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
0
1
2
1

output:

? 1
? 500000
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 6
? 15630
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 60
? 53
? 46
? 50
? 52
! 51

result:

ok Correct position at 51

Test #26:

score: 0
Accepted
time: 3ms
memory: 3424kb

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
13
12
11
10
11
11

output:

? 1
? 500001
? 750001
? 875001
? 937501
? 968751
? 984376
? 992189
? 996095
? 998048
? 999025
? 999513
? 999757
? 999879
? 999818
? 999788
? 999773
? 999781
! 999781

result:

ok Correct position at 999781

Test #27:

score: 0
Accepted
time: 3ms
memory: 3432kb

input:

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

output:

? 1
? 500001
? 750001
? 875001
? 937501
? 968751
? 984376
? 992188
? 996094
? 998047
? 999024
? 999512
? 999756
? 999878
? 999939
? 999970
? 999985
? 999978
? 999982
? 999980
! 999980

result:

ok Correct position at 999980

Test #28:

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

input:

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

output:

? 1
? 500000
? 750000
? 875000
? 937500
? 968750
? 984375
? 992187
? 996093
? 998046
? 999023
? 999511
? 999755
? 999877
? 999938
? 999969
? 999984
? 999977
? 999981
? 999979
! 999979

result:

ok Correct position at 999979

Test #29:

score: 0
Accepted
time: 3ms
memory: 3384kb

input:

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

output:

? 1
? 500000
? 749999
? 874999
? 937499
? 968749
? 984374
? 992186
? 996092
? 998045
? 999022
? 999510
? 999754
? 999876
? 999937
? 999968
? 999983
? 999976
? 999980
? 999978
! 999978

result:

ok Correct position at 999978

Test #30:

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

input:

1000000
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
12
11
12
13

output:

? 1
? 500001
? 2
? 250002
? 375002
? 437502
? 468752
? 484377
? 492189
? 496095
? 498048
? 499025
? 499513
? 499757
? 499879
? 499940
? 499971
? 499956
? 499948
? 499944
? 499946
! 499947

result:

ok Correct position at 499947

Test #31:

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

input:

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

output:

? 1
? 500001
? 750001
? 625001
? 500002
? 562502
? 500003
? 531253
? 500004
? 515629
? 500005
? 507817
? 500006
? 503912
? 500007
? 501960
? 500008
? 500984
? 500009
? 500497
? 500010
? 500254
? 500011
? 500133
? 500012
? 500073
? 500013
? 500043
? 500058
? 500066
? 500070
! 500070

result:

ok Correct position at 500070

Test #32:

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

input:

999998
1
2
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
0
1
0
1
0
1

output:

? 1
? 500000
? 750000
? 625000
? 500001
? 562501
? 500002
? 531252
? 500003
? 515628
? 500004
? 507816
? 500005
? 503911
? 500006
? 501959
? 500007
? 500983
? 500008
? 500496
? 500009
? 500253
? 500010
? 500132
? 500011
? 500072
? 500102
? 500087
? 500073
? 500080
? 500074
? 500077
? 500075
! 500076

result:

ok Correct position at 500076

Test #33:

score: 0
Accepted
time: 3ms
memory: 3336kb

input:

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

output:

? 1
? 500000
? 2
? 250001
? 375001
? 437501
? 468751
? 484376
? 492188
? 496094
? 498047
? 499024
? 499512
? 499756
? 499878
? 499939
? 499970
? 499955
? 499963
? 499967
? 499965
! 499965

result:

ok Correct position at 499965

Test #34:

score: 0
Accepted
time: 4ms
memory: 3424kb

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
1
0
1
0
1
0
1
0
0

output:

? 1
? 500001
? 2
? 250002
? 3
? 125003
? 4
? 62504
? 5
? 31255
? 6
? 15631
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 16
? 31
? 17
? 24
? 18
? 21
? 19
! 19

result:

ok Correct position at 19

Test #35:

score: 0
Accepted
time: 5ms
memory: 3452kb

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
0
1
0
1
0
1
0
0

output:

? 1
? 500001
? 2
? 250002
? 3
? 125003
? 4
? 62504
? 5
? 31255
? 6
? 15631
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 16
? 31
? 17
? 24
? 18
? 21
? 19
! 19

result:

ok Correct position at 19

Test #36:

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

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
0
1
0
1
0
1
0
0

output:

? 1
? 500000
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 6
? 15630
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 16
? 31
? 17
? 24
? 18
? 21
? 19
! 19

result:

ok Correct position at 19

Test #37:

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

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
0
1
0
1
0
1
0
0

output:

? 1
? 500000
? 2
? 250001
? 3
? 125002
? 4
? 62503
? 5
? 31254
? 6
? 15630
? 7
? 7819
? 8
? 3914
? 9
? 1962
? 10
? 986
? 11
? 499
? 12
? 256
? 13
? 135
? 14
? 75
? 15
? 45
? 16
? 31
? 17
? 24
? 18
? 21
? 19
! 19

result:

ok Correct position at 19

Test #38:

score: 0
Accepted
time: 4ms
memory: 3432kb

input:

1000000
1
2
3
4
5
6
7
6
5
4
5
4
3
2
1
2
1
2
3
4

output:

? 1
? 500001
? 750001
? 875001
? 937501
? 968751
? 984376
? 992189
? 988283
? 986330
? 985353
? 985842
? 985598
? 985476
? 985415
? 985384
? 985400
? 985392
? 985396
? 985398
! 985399

result:

ok Correct position at 985399

Test #39:

score: 0
Accepted
time: 4ms
memory: 3432kb

input:

999999
1
0
1
0
1
0
1
0
1
0
1
0
1
2
3
4
3
2
1
0
1
2
1
0
1
0
1
0
1
1

output:

? 1
? 500001
? 2
? 250002
? 3
? 125003
? 4
? 62504
? 5
? 31255
? 6
? 15631
? 7
? 7819
? 11725
? 13678
? 14655
? 14167
? 13923
? 13801
? 13679
? 13740
? 13771
? 13756
? 13741
? 13749
? 13742
? 13746
? 13743
? 13745
! 13745

result:

ok Correct position at 13745

Test #40:

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

input:

999998
1
2
1
2
3
4
5
4
3
2
3
2
1
0
1
2
1
0
1
0
1
0
1
1

output:

? 1
? 500000
? 750000
? 625000
? 687500
? 718750
? 734375
? 742188
? 738282
? 736329
? 735352
? 735841
? 735597
? 735475
? 735353
? 735414
? 735445
? 735430
? 735415
? 735423
? 735416
? 735420
? 735417
? 735419
! 735419

result:

ok Correct position at 735419

Test #41:

score: 0
Accepted
time: 3ms
memory: 3436kb

input:

999997
1
0
1
2
1
2
3
4
3
2
1
2
1
0
1
2
3
2
1
2
3
4

output:

? 1
? 500000
? 2
? 250001
? 375001
? 312501
? 343751
? 359376
? 367189
? 363283
? 361330
? 360353
? 360842
? 360598
? 360354
? 360476
? 360537
? 360568
? 360553
? 360545
? 360549
? 360551
! 360552

result:

ok Correct position at 360552

Test #42:

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

input:

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

output:

? 1
? 500001
? 750001
? 875001
? 937501
? 968751
? 984376
? 992189
? 996095
? 998048
? 999025
? 999513
? 999757
? 999879
? 999940
? 999971
? 999986
? 999994
? 999998
? 1000000
! 1000000

result:

ok Correct position at 1000000

Test #43:

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

input:

1000000
0

output:

? 1
! 1

result:

ok Correct position at 1