Submission #728454

#TimeUsernameProblemLanguageResultExecution timeMemory
728454MBICombo (IOI18_combo)C++17
97 / 100
33 ms540 KiB
#include "combo.h" // #include <iostream> using namespace std; string guess_sequence(int N) { int l=1,k; string s; if (press("A")){ s="A"; while (l<N){ if (l==N-1){ k=press(s+"B"); if (k>l) s+="B"; else if ((k=press(s+"X"))>l) s+="X"; else s+="Y"; break; } k=press(s+"B"+s+"XB"+s+"XX"+s+"XY"); if (k==l) { s+="Y"; l++; } if (k==l+1){ s+="B"; l++; } if (k==l+2){ s+="X"; l++; } } } else if (press("B")){ s="B"; while (l<N){ if (l==N-1){ k=press(s+"A"); if (k>l) s+="A"; else if ((k=press(s+"X"))>l) s+="X"; else s+="Y"; break; } k=press(s+"A"+s+"XA"+s+"XX"+s+"XY"); if (k==l) { s+="Y"; l++; } if (k==l+1){ s+="A"; l++; } if (k==l+2){ s+="X"; l++; } } } else if (press("X")){ s="X"; while (l<N){ if (l==N-1){ k=press(s+"B"); if (k>l) s+="B"; else if ((k=press(s+"A"))>l) s+="A"; else s+="Y"; break; } k=press(s+"B"+s+"AB"+s+"AA"+s+"AY"); if (k==l) { s+="Y"; l++; } if (k==l+1){ s+="B"; l++; } if (k==l+2){ s+="A"; l++; } } } else { s="Y"; while (l<N){ if (l==N-1){ k=press(s+"B"); if (k>l) s+="B"; else if ((k=press(s+"X"))>l) s+="X"; else s+="A"; break; } k=press(s+"B"+s+"XB"+s+"XX"+s+"XA"); if (k==l) { s+="A"; l++; } if (k==l+1){ s+="B"; l++; } if (k==l+2){ s+="X"; l++; } } } // cerr << s << " \n"; return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...