QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371544#6394. Turn on the LightHosamaJJFWA 0ms3704kbC++17667b2024-03-30 13:52:532024-03-30 13:52:55

Judging History

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

  • [2024-03-30 13:52:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2024-03-30 13:52:53]
  • 提交

answer

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

int n,x,xx;

int main(){
    cin>>n;
    cout<<"? 1\n";
    cout.flush();
    cin>>x;
    if(x==0){
        cout<<"! 1\n";
        cout.flush();
        return 0;
    }
    int t=40,l=1,r=n;
    while(l<=r){
        int mid=(l+r)>>1;
        cout<<"? "<<mid<<"\n";
        cout.flush();
        cin>>xx;
        //cout<<"- "<<xx<<"\n";
        if(xx<x){
            r=mid-1;
        }
        else if(xx>x){
            l=mid+1;
        }
        else {
            cout<<"! "<<mid<<"\n";
            cout.flush();
            break;
        }
        x=xx;
    }   

    return 0;
}

详细

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
3

output:

? 1
? 5
? 8
? 9
! 9

result:

ok Correct position at 9

Test #3:

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

input:

9
1
2
3
3

output:

? 1
? 5
? 7
? 8
! 8

result:

ok Correct position at 8

Test #4:

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

input:

8
1
2
3
3

output:

? 1
? 4
? 6
? 7
! 7

result:

ok Correct position at 7

Test #5:

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

input:

7
1
2
3
3

output:

? 1
? 4
? 6
? 7
! 7

result:

ok Correct position at 7

Test #6:

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

input:

6
1
2
3
3

output:

? 1
? 3
? 5
? 6
! 6

result:

ok Correct position at 6

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 3
? 4
? 5
! 5

result:

ok Correct position at 5

Test #8:

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

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3664kb

input:

2
1
1

output:

? 1
? 1
! 1

result:

wrong answer Wrong favorite light!