Submission #278836

#TimeUsernameProblemLanguageResultExecution timeMemory
278836themax23Combo (IOI18_combo)C++17
100 / 100
40 ms580 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { //first part: Getting the first letter string first = ""; int fcoin = press("XY"); if (fcoin){ if(press("X")) first = "X"; else first = "Y"; } else{ if(press("A")) first = "A"; else first = "B"; } if(N == 1) return first; string posibles = "",ans = first; if(first == "A") posibles = "BXY"; else if(first == "B") posibles = "AXY"; else if(first == "X") posibles = "ABY"; else posibles = "ABX"; for(int i = 1; i < N -1; ++i){ string test = ans + posibles[0] + posibles[0] + ans + posibles[0] + posibles[1] + ans + posibles[0] + posibles[2] + ans + posibles[1]; int coins = press(test); if(coins > i+1) ans += posibles[0]; else if(coins > i) ans += posibles[1]; else ans += posibles[2]; } for(int i = 0; i < 2; ++i){ if(press(ans + posibles[i]) == N) return ans + posibles[i]; } return ans + posibles[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...