QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397573#6394. Turn on the Lightryh7#WA 0ms3636kbC++17700b2024-04-24 13:23:062024-04-24 13:23:06

Judging History

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

  • [2024-04-24 13:23:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-04-24 13:23:06]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ull;
int n;
int main() {
    cin>>n;
    int left = 1 , right = n;
    int val = 0;
    while(left < right){
        int mid = (left + right) >> 1;
        cout<<("? ")<<mid<<"\n";
        cout.flush();
       // s.insert(mid);
        int t;
        cin>>t;
        if(t > val){
            left = mid + 1;
        }else if(t < val){
            right = mid - 1;
        }else if(t == val){
            cout<<"! "<<mid<<'\n';
            return 0;
        }

    }
    cout<<"! "<<left<<'\n';
    return 0;
}

详细

Test #1:

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

input:

3
1

output:

? 2
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3

output:

? 5
? 8
? 9
! 10

result:

wrong answer Wrong answer, more than 1 possible light!