結果

問題 No.1187 皇帝ペンギン
ユーザー WarToks
提出日時 2020-08-22 15:06:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 75,444 KB
実行使用メモリ 25,580 KB
平均クエリ数 16.48
最終ジャッジ日時 2024-07-17 06:24:13
合計ジャッジ時間 10,188 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>

char S[10];

bool ask(const int v, int& t){
    --t; std::cout << "? " << v << '\n'; std::cin >> S;
    return S[0] == 's';
}

int main(void){
    int ok = 0, ng = 1000;
    int ask_t = 25;
    while(ng - ok > 1){
        const int mid = (ok + ng) / 2;
        if(ask(mid, ask_t)) ok = mid;
        else{
            if(ask(mid + 1, ask_t)) ok = mid + 1;
            else ng = mid;
        }
        if(ask_t > 25) return 1;
    }
    std::cout << ok << '\n';    
    return 0;
}
0