Submission #706514

#TimeUsernameProblemLanguageResultExecution timeMemory
706514Urvuk3Combo (IOI18_combo)C++17
100 / 100
31 ms644 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; #define ll long long const int INF=1e9; const ll LINF=1e18; #define fi first #define se second #define pii pair<int,int> #define mid ((l+r)/2) #define sz(a) (int((a).size())) #define all(a) a.begin(),a.end() #define endl "\n" #define PRINT(x) cerr<<#x<<'='<<x<<endl; #define pb push_back #define PRINTvec(niz) { cerr<<#niz<<"="; for(auto _i:niz) cerr<<_i<<" "; cerr<<endl; } string guess_sequence(int N){ if(N>1){ int p=press("AB"); string S="",T; if(p==2) S="A"; else if(p==1){ p=press("A"); if(p==1) S="A"; else S="B"; } else{ p=press("X"); if(p==1) S="X"; else S="Y"; } T+=S[0]; for(auto c:{'A','B','X','Y'}){ if(c!=S[0]) T+=c; } while(sz(S)<N-1){ string ask=S+T[1]+T[1]+S+T[1]+T[2]+S+T[1]+T[3]+S+T[2]; p=press(ask); if(p==sz(S)+2) S.pb(T[1]); else if(p==sz(S)+1) S.pb(T[2]); else S.pb(T[3]); } p=press(S+T[1]); if(p==N) return S+T[1]; p=press(S+T[2]); if(p==N) return S+T[2]; return S+T[3]; } else{ int p=press("A"); if(p) return "A"; p=press("B"); if(p) return "B"; p=press("X"); if(p) return "X"; return "Y"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...