結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main() {
    string s;
    int ok = 0, ng = 1000, D = -1;
    while (ok + 1 < ng) {
        int x = (ok + ng) / 2;
        if (D != -1 && x % D == 0) {
            x++;
            if (x == ng) break;
        }
        cout << "? " << x << "\n";
        cin >> s;
        if (s == "safe") {
            ok = x;
            continue;
        }
        cout << "? " << x + 1 << "\n";
        cin >> s;
        if (s == "out") {
            ng = x;
        } else {
            ok = x + 1;
        }
    }
    cout << "! " << ok << "\n";
}
0