Submission #983579

#TimeUsernameProblemLanguageResultExecution timeMemory
983579user736482Combo (IOI18_combo)C++17
100 / 100
13 ms1728 KiB
#include <bits/stdc++.h> #include <combo.h> using namespace std; /*string S="ABX"; int press(string p){ cout<<p<<" "; int len = p.length(); int coins = 0; for (int i = 0, j = 0; i < len; ++i) { if (j < S.size() && S[j] == p[i]) { ++j; } else if (S[0] == p[i]) { j = 1; } else { j = 0; } coins = max(coins, j); } return coins; }*/ string guess_sequence(int N){ string result; int guessresult; guessresult = press("AB"); if(guessresult){ guessresult = press("A"); if(guessresult) result = "A"; else result = "B"; } else{ guessresult = press("X"); if(guessresult) result = "X"; else result = "Y"; } if(N==1) return result; if(result[0]=='A') for(int i=0;i<N-2;i++){ guessresult = press(result + "B" + result + "XB" + result + "XX" + result + "XY"); if(guessresult == (int)result.size()+1){ result.push_back('B'); } else if(guessresult == (int)result.size()){ result.push_back('Y'); } else{ result.push_back('X'); } } if(result[0]=='B') for(int i=0;i<N-2;i++){ guessresult = press(result + "A" + result + "XA" + result + "XX" + result + "XY"); if(guessresult == (int)result.size()+1){ result.push_back('A'); } else if(guessresult == (int)result.size()){ result.push_back('Y'); } else{ result.push_back('X'); } } else if(result[0]=='X') for(int i=0;i<N-2;i++){ guessresult = press(result + "B" + result + "AB" + result + "AA" + result + "AY"); if(guessresult == (int)result.size()+1){ result.push_back('B'); } else if(guessresult == (int)result.size()){ result.push_back('Y'); } else{ result.push_back('A'); } } else if(result[0]=='Y') for(int i=0;i<N-2;i++){ guessresult = press(result + "B" + result + "XB" + result + "XX" + result + "XA"); if(guessresult == (int)result.size()+1){ result.push_back('B'); } else if(guessresult == (int)result.size()){ result.push_back('A'); } else{ result.push_back('X'); } } if(result[0] == 'X'){ guessresult = press(result+"A"+result+"B"); if(guessresult == N){ guessresult = press(result+"A"); if(guessresult == N) result.push_back('A'); else result.push_back('B'); } else{ result.push_back('Y'); }} if(result[0] == 'Y'){ guessresult = press(result+"A"+result+"B"); if(guessresult == N){ guessresult = press(result+"A"); if(guessresult == N) result.push_back('A'); else result.push_back('B'); } else{ result.push_back('X'); }} if(result[0] == 'A'){ guessresult = press(result+"X"+result+"B"); if(guessresult == N){ guessresult = press(result+"X"); if(guessresult == N) result.push_back('X'); else result.push_back('B'); } else{ result.push_back('Y'); }} if(result[0] == 'B'){ guessresult = press(result+"A"+result+"X"); if(guessresult == N){ guessresult = press(result+"A"); if(guessresult == N) result.push_back('A'); else result.push_back('X'); } else{ result.push_back('Y'); }} return result; } /*int main(){ cout<<guess_sequence(3); }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...