Submission #97657

#TimeUsernameProblemLanguageResultExecution timeMemory
97657arnold518Combo (IOI18_combo)C++14
100 / 100
43 ms932 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; string ans; char start; string guess_sequence(int n) { int i, j; string t; ans.clear(); int p=press("AX"), q=press("AY"); if(p==0 && q==0) start='B'; else if(p==0 && q!=0) start='Y'; else if(p!=0 && q==0) start='X'; else if(p!=0 && q!=0) start='A'; ans+=start; if(n==1) return ans; for(i=2; i<n; i++) { if(start=='A') t=ans+"BB"+ans+"BX"+ans+"BY"+ans+"X"; else if(start=='B') t=ans+"XX"+ans+"XY"+ans+"XA"+ans+"Y"; else if(start=='X') t=ans+"YY"+ans+"YA"+ans+"YB"+ans+"A"; else if(start=='Y') t=ans+"AA"+ans+"AB"+ans+"AX"+ans+"B"; int res=press(t); //cout<<i<<" "<<t<<" "<<res<<" "<<ans<<endl; res-=i-1; if(start=='A') { if(res==0) ans+='Y'; else if(res==1) ans+='X'; else if(res==2) ans+='B'; } else if(start=='B') { if(res==0) ans+='A'; else if(res==1) ans+='Y'; else if(res==2) ans+='X'; } else if(start=='X') { if(res==0) ans+='B'; else if(res==1) ans+='A'; else if(res==2) ans+='Y'; } else if(start=='Y') { if(res==0) ans+='X'; else if(res==1) ans+='B'; else if(res==2) ans+='A'; } } if(start=='A') { if(press(ans+'B')==n) ans+='B'; else if(press(ans+'X')==n) ans+='X'; else ans+='Y'; } else if(start=='B') { if(press(ans+'A')==n) ans+='A'; else if(press(ans+'X')==n) ans+='X'; else ans+='Y'; } else if(start=='X') { if(press(ans+'A')==n) ans+='A'; else if(press(ans+'B')==n) ans+='B'; else ans+='Y'; } else if(start=='Y') { if(press(ans+'A')==n) ans+='A'; else if(press(ans+'B')==n) ans+='B'; else ans+='X'; } //cout<<ans<<endl; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:14:12: warning: unused variable 'j' [-Wunused-variable]
   14 |     int i, j;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...