QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574180#6394. Turn on the Light123adadWA 1ms3732kbC++201.1kb2024-09-18 21:00:472024-09-18 21:00:47

Judging History

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

  • [2024-09-18 21:00:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3732kb
  • [2024-09-18 21:00:47]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long

using namespace std;
void solve()
{
    int n,pr=0,nx,m,f=0;
    cin >> n;
    int l=1,r=n,x;
    cout << "? " << 1 << endl;
    cin >> nx;
    if(nx==0){
        cout << "! " << 1 << endl;
        return;
    }
    for(int i=2;i<=20;i++){
        pr=nx;
        cout << "? " << i << endl;
        cin >> nx;
        if(nx==pr){
            cout << "! " << i;
            return;
        }
    }
    //cout.flush();
    l=20;
    while(1){
        int m=(l+r)>>1;
        //cout <<l << " " << r << " " << m << "* ";
        cout << "? " << m << endl;
        pr=nx;
        cin >> nx;
        if(m==r-1){
            cout << r << endl;
            break;
        }
        if(nx==pr){
            cout << "! " << m;
            break;
        }
        else if(nx==pr+1){
            l=m;
        }
        else {
            r=m;
        }
    }
    //cout << (2<<20);
}
int main()
{
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}

//cout << "work" << "\n";

详细

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

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

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

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

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

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

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

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

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 15
? 16
? 17
? 18
? 19
? 20
? 500010
? 750005
? 875002
? 937501
? 968750
? 984375
? 992187
? 996093
? 998046
? 999023
? 999511
? 999755
? 999877
? 999938
? 999969
? 999984
? 999992
? 999996
? 999998
? 999999
1000000

result:

wrong answer Token parameter [name=type] equals to "1000000", doesn't correspond to pattern "?|!"