1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| #include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll query(ll x){ cout<<"walk "<<x<<endl; cin>>x; return x; }
void guess(ll x){ cout<<"guess "<<x<<endl; exit(0); }
int main(){ std::random_device rd; std::default_random_engine eng(rd()); std::uniform_int_distribution<int> num(1,(int)1e9); ll ma=0,x; for(int i=1;i<=3333;++i)ma=max(ma,query(num(eng))); ll step=0; map<ll,ll>cn; for(int i=1;i<=3333;++i){ step+=1,x=query(1); if(cn.count(x))guess(step-cn[x]); else cn[x]=step; } step+=ma,x=query(ma); if(cn.count(x))guess(step-cn[x]); else cn[x]=step; for(int i=1;i<=3333;++i){ step+=3333,x=query(3333); if(cn.count(x))guess(step-cn[x]); else cn[x]=step; } guess(ma); }
|