結果

問題 No.1187 皇帝ペンギン
ユーザー maguromaguro
提出日時 2020-08-22 14:31:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 1,512 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 199,168 KB
実行使用メモリ 24,324 KB
平均クエリ数 19.70
最終ジャッジ日時 2023-09-24 06:02:19
合計ジャッジ時間 5,470 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,532 KB
testcase_01 AC 21 ms
23,424 KB
testcase_02 AC 23 ms
24,144 KB
testcase_03 AC 20 ms
23,268 KB
testcase_04 AC 20 ms
24,252 KB
testcase_05 AC 20 ms
23,436 KB
testcase_06 AC 21 ms
23,640 KB
testcase_07 AC 20 ms
24,012 KB
testcase_08 AC 20 ms
23,724 KB
testcase_09 AC 21 ms
23,436 KB
testcase_10 AC 21 ms
23,364 KB
testcase_11 AC 21 ms
23,412 KB
testcase_12 AC 20 ms
23,424 KB
testcase_13 AC 20 ms
23,376 KB
testcase_14 AC 20 ms
23,364 KB
testcase_15 AC 20 ms
24,276 KB
testcase_16 AC 20 ms
23,280 KB
testcase_17 AC 22 ms
23,688 KB
testcase_18 AC 22 ms
24,276 KB
testcase_19 AC 22 ms
23,520 KB
testcase_20 AC 24 ms
23,904 KB
testcase_21 AC 20 ms
23,988 KB
testcase_22 AC 20 ms
23,700 KB
testcase_23 AC 22 ms
23,916 KB
testcase_24 AC 24 ms
23,724 KB
testcase_25 AC 21 ms
23,916 KB
testcase_26 AC 21 ms
24,144 KB
testcase_27 AC 22 ms
23,868 KB
testcase_28 AC 20 ms
24,156 KB
testcase_29 AC 21 ms
23,904 KB
testcase_30 AC 21 ms
24,288 KB
testcase_31 AC 21 ms
24,000 KB
testcase_32 AC 20 ms
23,820 KB
testcase_33 AC 20 ms
23,304 KB
testcase_34 AC 21 ms
24,288 KB
testcase_35 AC 23 ms
23,304 KB
testcase_36 AC 23 ms
23,616 KB
testcase_37 AC 20 ms
23,436 KB
testcase_38 AC 20 ms
23,904 KB
testcase_39 AC 22 ms
23,736 KB
testcase_40 AC 20 ms
24,264 KB
testcase_41 AC 23 ms
23,544 KB
testcase_42 AC 20 ms
24,204 KB
testcase_43 AC 21 ms
23,604 KB
testcase_44 AC 21 ms
23,916 KB
testcase_45 AC 20 ms
23,736 KB
testcase_46 AC 20 ms
23,304 KB
testcase_47 AC 20 ms
23,412 KB
testcase_48 AC 19 ms
23,832 KB
testcase_49 AC 20 ms
23,304 KB
testcase_50 AC 20 ms
24,180 KB
testcase_51 AC 20 ms
24,324 KB
testcase_52 AC 20 ms
23,928 KB
testcase_53 AC 25 ms
23,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mod(ll val, ll M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

// N^P mod M(ただしM == -1の時はmodを取らない)
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int ok = 0;
    int ng = 1010;
    int mid = 0;
    while(ng - ok > 1) {
        mid = (ok + ng) / 2;
        string A,B;
        cout << "? " << mid << endl;
        cin >> A;
        cout << "? " << mid + 1 << endl;
        cin >> B;
        if(A == "out" && B == "out") {
            ng = mid;
        }
        else {
            if(B == "safe") {
                ok = mid + 1;
            }
            else if(A == "safe") {
                ok = mid;
            }
        }
    }
    cout << "! " << ok << endl;
}
0