結果
問題 | No.1187 皇帝ペンギン |
ユーザー |
![]() |
提出日時 | 2020-08-23 18:26:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 1,000 ms |
コード長 | 884 bytes |
コンパイル時間 | 1,071 ms |
コンパイル使用メモリ | 92,784 KB |
実行使用メモリ | 25,580 KB |
平均クエリ数 | 16.48 |
最終ジャッジ日時 | 2024-07-17 06:42:12 |
合計ジャッジ時間 | 5,447 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 54 |
ソースコード
/* -*- coding: utf-8 -*- * * 1187.cc: No.1187 皇帝ペンギン - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_N = 1000; /* typedef */ /* global variables */ /* subroutines */ bool check(int x) { printf("? %d\n", x); fflush(stdout); char s[8]; scanf("%s", s); return (s[0] == 's'); } /* main */ int main() { int x0 = 0, x1 = MAX_N; while (x0 + 1 < x1) { int x = (x0 + x1) / 2; if (check(x)) x0 = x; else if (check(x + 1)) x0 = x + 1; else x1 = x; } printf("! %d\n", x1 - 1); fflush(stdout); return 0; }