結果

問題 No.1187 皇帝ペンギン
ユーザー WarToks
提出日時 2020-08-22 15:10:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 620 bytes
コンパイル時間 1,104 ms
コンパイル使用メモリ 77,932 KB
最終ジャッジ日時 2025-01-13 09:13:47
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 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 < 0) return 1;
    }
    std::cout << "! " << ok << '\n';    
    return 0;
}
0