結果

問題 No.2252 Find Zero
ユーザー SSRS
提出日時 2023-03-24 21:24:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 360 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 166,320 KB
実行使用メモリ 25,820 KB
平均クエリ数 196.00
最終ジャッジ日時 2024-09-18 16:40:11
合計ジャッジ時間 4,081 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = -1;
  for (int i = 0; i < N; i += 2){
    cout << "? " << i << ' ' << i + 1 << endl;
    int z;
    cin >> z;
    if (z == i){
      ans = i + 1;
    }
    if (z == i + 1){
      ans = i;
    }
  }
  if (ans == -1){
    ans = N - 1;
  }
  cout << "! " << ans << endl;
}
0