Submission #283464

#TimeUsernameProblemLanguageResultExecution timeMemory
283464Ruba_KCombo (IOI18_combo)C++14
100 / 100
44 ms664 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std ; std::string guess_sequence(int N) { string p = ""; char A = 'A' , B = 'B' , X = 'X' , Y = 'Y'; string first = "AB" , second = "XY"; int coins = press(first); if(coins){ coins = press("A"); if(coins)p += 'A'; else p += 'B' , swap(A , B); } else { coins = press("X"); if(coins) p+= 'X' , swap(A , X); else p += 'Y' , swap(A , Y); } coins = 1 ; if(N == 1)return p ; int curr = coins ; string S = p ; while(curr < N - 1){ p = S + B ; p += S + X + B ; p += S + X + X ; p += S + X + Y ; coins = press(p); if(coins - curr == 0)S.push_back(Y); else if(coins - curr == 1)S.push_back(B); else S.push_back(X); curr ++ ; } S += B ; coins = press(S ); if(coins == N)return S ; S.pop_back() ; S += X ; coins = press(S); if(coins == N)return S ; S.pop_back(); S.push_back(Y); return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...