結果

問題 No.1187 皇帝ペンギン
ユーザー SSRS
提出日時 2020-08-22 13:26:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 32 ms / 1,000 ms
コード長 555 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 167,536 KB
実行使用メモリ 25,464 KB
平均クエリ数 21.96
最終ジャッジ日時 2024-07-17 06:09:37
合計ジャッジ時間 5,852 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int tv = 0;
  int fv = 1000;
  while (fv - tv > 1){
    int mid = (tv + fv) / 2;
    cout << "? " << mid << endl;
    string S1;
    cin >> S1;
    cout << "? " << mid + 1 << endl;
    string S2;
    cin >> S2;
    if (S1 == "out" && S2 == "out"){
      fv = mid;
    } else {
      tv = mid;
    }
  }
  int ans = tv;
  while (1){
    cout << "? " << ans << endl;
    string S;
    cin >> S;
    if (S == "out"){
      ans--;
    } else {
      break;
    }
  }
  cout << "! " << ans << endl;
}
0