QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#407469#6394. Turn on the Lightnageing#TL 0ms0kbC++20642b2024-05-08 19:20:412024-05-08 19:20:43

Judging History

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

  • [2024-05-08 19:20:43]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-05-08 19:20:41]
  • 提交

answer

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

int query(int x) {
    cout << "? " << x << '\n';
    int res;
    cin >> res;
    return res;
}

void solve() {
    int n;
    cin >> n;
    int l = 0, r = n + 1;
    
    while (n -- && l < r) {
        int mid = l + r >> 1;
        int x = query(mid);
        if (x > 0) {
            l = mid + 1;
        } else {
            r = mid;
        }
    }
    cout << "! " << l - 1 << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    int t;
    t = 1;
    while (t --) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

3

output:


result: