QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371744#6394. Turn on the Lightacansaidong#WA 2ms3916kbC++23978b2024-03-30 15:22:512024-03-30 15:22:53

Judging History

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

  • [2024-03-30 15:22:53]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3916kb
  • [2024-03-30 15:22:51]
  • 提交

answer

#include <bits/stdc++.h>
#include <sstream>

//#define int long long
#define endl '\n'
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;

using namespace std;

signed main() {
    int n,x,y;
    cin>>n;
    int a=0,aa=0;
    int l=1,r=n;
    while(l<=r) {
    	int x,y;
        printf("? %d\n",l);
        cin>>x;
        if(x==a)
        {
			printf("! %d\n",l);return 0;
		}
		if(l!=(l+r)/2)
		{
			printf("? %d\n",(l+r)/2);
			cin>>y;
			if(y==x)
	        {
				printf("! %d\n",(l+r)/2);return 0;
			}
			else if(x<y)
			{
				l=(l+r)/2+1;
			}
			else if(x>y)
			{
				r=(l+r)/2-1;
			}
	        a=y;
		}
		else
		{
			printf("? %d\n",(l+r)/2+1);
			cin>>y;
			if(y==x)
	        {
				printf("! %d\n",(l+r)/2+1);return 0;
			}
			else if(x<y)
			{
				l=(l+r)/2+1+1;
			}
			else if(x>y)
			{
				r=(l+r)/2-1+1;
			}
	        a=y;
		}
    }
    printf("! %d",l);
    return 0;
}

详细

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
5

output:

? 1
? 5
? 6
? 8
? 9
? 10
! 10

result:

ok Correct position at 10

Test #3:

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

input:

9
1
2
3
4
5
5

output:

? 1
? 5
? 6
? 7
? 8
? 9
! 9

result:

ok Correct position at 9

Test #4:

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

input:

8
1
2
3
4
5
5

output:

? 1
? 4
? 5
? 6
? 7
? 8
! 8

result:

ok Correct position at 8

Test #5:

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

input:

7
1
2
3
3

output:

? 1
? 4
? 5
? 6
! 6

result:

ok Correct position at 6

Test #6:

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

input:

6
1
2
3
3

output:

? 1
? 3
? 4
? 5
! 5

result:

ok Correct position at 5

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 3
? 4
? 5
! 5

result:

ok Correct position at 5

Test #8:

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

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

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:

? 1
? 500000
? 500001
? 750000
? 750001
? 875000
? 875001
? 937500
? 937501
? 968750
? 968751
? 984375
? 984376
? 992188
? 992189
? 996094
? 996095
? 998047
? 998048
? 999024
? 999025
? 999512
? 999513
? 999756
? 999757
? 999878
? 999879
? 999939
? 999940
? 999970
? 999971
? 999985
? 999986
? 999993...

result:

ok Correct position at 1000000

Test #13:

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

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:

? 1
? 500000
? 500001
? 750000
? 750001
? 875000
? 875001
? 937500
? 937501
? 968750
? 968751
? 984375
? 984376
? 992187
? 992188
? 996093
? 996094
? 998046
? 998047
? 999023
? 999024
? 999511
? 999512
? 999755
? 999756
? 999877
? 999878
? 999938
? 999939
? 999969
? 999970
? 999984
? 999985
? 999992...

result:

ok Correct position at 999999

Test #14:

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

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:

? 1
? 499999
? 500000
? 749999
? 750000
? 874999
? 875000
? 937499
? 937500
? 968749
? 968750
? 984374
? 984375
? 992186
? 992187
? 996092
? 996093
? 998045
? 998046
? 999022
? 999023
? 999510
? 999511
? 999754
? 999755
? 999876
? 999877
? 999937
? 999938
? 999968
? 999969
? 999983
? 999984
? 999991...

result:

ok Correct position at 999998

Test #15:

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

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:

? 1
? 499999
? 500000
? 749998
? 749999
? 874998
? 874999
? 937498
? 937499
? 968748
? 968749
? 984373
? 984374
? 992185
? 992186
? 996091
? 996092
? 998044
? 998045
? 999021
? 999022
? 999509
? 999510
? 999753
? 999754
? 999875
? 999876
? 999936
? 999937
? 999967
? 999968
? 999982
? 999983
? 999990...

result:

ok Correct position at 999997

Test #16:

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

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

output:

? 1
? 499998
? 499999
? 749997
? 749998
? 874997
? 874998
? 937497
? 937498
? 968747
? 968748
? 984372
? 984373
? 992184
? 992185
? 996090
? 996091
? 998043
? 998044
? 999020
? 999021
? 999508
? 999509
? 999752
? 999753
? 999874
? 999875
? 999935
? 999936
? 999966
? 999967
? 999981
? 999982
? 999989...

result:

ok Correct position at 999996

Test #17:

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

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

output:

? 1
? 499998
? 499999
? 749997
? 749998
? 874996
? 874997
? 937496
? 937497
? 968746
? 968747
? 984371
? 984372
? 992183
? 992184
? 996089
? 996090
? 998042
? 998043
? 999019
? 999020
? 999507
? 999508
? 999751
? 999752
? 999873
? 999874
? 999934
? 999935
? 999965
? 999966
? 999980
? 999981
? 999988...

result:

ok Correct position at 999995

Test #18:

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

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

output:

? 1
? 499997
? 499998
? 749996
? 749997
? 874995
? 874996
? 937495
? 937496
? 968745
? 968746
? 984370
? 984371
? 992182
? 992183
? 996088
? 996089
? 998041
? 998042
? 999018
? 999019
? 999506
? 999507
? 999750
? 999751
? 999872
? 999873
? 999933
? 999934
? 999964
? 999965
? 999979
? 999980
? 999987...

result:

ok Correct position at 999994

Test #19:

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

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

output:

? 1
? 499997
? 499998
? 749995
? 749996
? 874994
? 874995
? 937494
? 937495
? 968744
? 968745
? 984369
? 984370
? 992181
? 992182
? 996087
? 996088
? 998040
? 998041
? 999017
? 999018
? 999505
? 999506
? 999749
? 999750
? 999871
? 999872
? 999932
? 999933
? 999963
? 999964
? 999978
? 999979
? 999986...

result:

ok Correct position at 999993

Test #20:

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

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

output:

? 1
? 499996
? 499997
? 749994
? 749995
? 874993
? 874994
? 937493
? 937494
? 968743
? 968744
? 984368
? 984369
? 992180
? 992181
? 996086
? 996087
? 998039
? 998040
? 999016
? 999017
? 999504
? 999505
? 999748
? 999749
? 999870
? 999871
? 999931
? 999932
? 999962
? 999963
? 999977
? 999978
? 999985...

result:

ok Correct position at 999992

Test #21:

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

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

output:

? 1
? 499996
? 499997
? 749994
? 749995
? 874993
? 874994
? 937492
? 937493
? 968742
? 968743
? 984367
? 984368
? 992179
? 992180
? 996085
? 996086
? 998038
? 998039
? 999015
? 999016
? 999503
? 999504
? 999747
? 999748
? 999869
? 999870
? 999930
? 999931
? 999961
? 999962
? 999976
? 999977
? 999984...

result:

ok Correct position at 999991

Test #22:

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

input:

1000000
1
0
0

output:

? 1
? 500000
? 1
! 1

result:

wrong answer Wrong favorite light!