結果
| 問題 | No.1187 皇帝ペンギン |
| コンテスト | |
| ユーザー |
ate
|
| 提出日時 | 2020-08-22 14:13:12 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 1,000 ms |
| コード長 | 706 bytes |
| 記録 | |
| コンパイル時間 | 1,335 ms |
| コンパイル使用メモリ | 221,272 KB |
| 実行使用メモリ | 30,308 KB |
| 平均クエリ数 | 16.70 |
| 最終ジャッジ日時 | 2026-06-12 16:52:43 |
| 合計ジャッジ時間 | 5,451 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 54 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<(n);++i)
signed main(){
auto question = [](ll x){
cout<<"? "<<x<<endl;
string s;
cin>>s;
return s;
};
if(question(1)=="out"){
cout<<"! "<<0<<endl;
return 0;
}
ll l=0,r=1e3+1;
map<ll,string> mp;
while(r-l>1){
ll m = (l+r)/2;
string s = (mp.count(m)?mp[m]:question(m));
if(s=="safe"){
mp[m] = s;
l=m;continue;
}
string t = (mp.count(m+1)?mp[m+1]:question(m+1));
if(s=="out" and t=="out"){
r = m;
}else{
if(s=="safe")l=m;
else l=m+1;
}
mp[m] = s;
mp[m+1] = t;
}
cout<<"! "<<l<<endl;
}
ate