結果

問題 No.2252 Find Zero
ユーザー jiangly
提出日時 2023-03-24 21:24:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 191,552 KB
最終ジャッジ日時 2025-02-11 16:56:01
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;
    std::cin >> N;
    
    for (int i = 0; i + 1 < N; i += 2) {
        std::cout << "? " << i << " " << i + 1 << std::endl;
        int res;
        std::cin >> res;
        if (res == i) {
            std::cout << "! " << i + 1 << std::endl;
            return 0;
        }
        if (res == i + 1) {
            std::cout << "! " << i << std::endl;
            return 0;
        }
    }
    
    std::cout << "! " << N - 1 << std::endl;
    
    return 0;
}
0