結果
| 問題 |
No.1187 皇帝ペンギン
|
| コンテスト | |
| ユーザー |
ate
|
| 提出日時 | 2020-08-22 14:13:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 43 ms / 1,000 ms |
| コード長 | 706 bytes |
| コンパイル時間 | 2,833 ms |
| コンパイル使用メモリ | 203,332 KB |
| 最終ジャッジ日時 | 2025-01-13 08:31:03 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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