QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#378431#6394. Turn on the LightlangodWA 0ms3596kbC++14884b2024-04-06 12:55:032024-04-06 12:55:03

Judging History

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

  • [2024-04-06 12:55:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-04-06 12:55:03]
  • 提交

answer

// Created by qyy on 2024/4/6.

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
int lastans, n, a[N];

void solve() {
    cin >> n;
    lastans = 0;
    int newans = 0;
    int l = 1, r = n;
    while(l <= r){
        int mid = (l + r) >> 1;
        cout << "? " << mid << endl;
        cin >> newans;
        if(newans == lastans){
            cout << "! " <<  mid << endl;
            return ;
        }else if(newans > lastans){
            l = mid + 1;
            lastans = newans;
        }else{
            r = mid - 1;
            lastans = newans;
        }
    }
}

signed main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4

output:

? 5
? 8
? 9
? 10

result:

wrong answer format  Unexpected end of file - token expected