Submission #873991

#TimeUsernameProblemLanguageResultExecution timeMemory
873991kh0iCombo (IOI18_combo)C++17
100 / 100
15 ms2016 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; #define sz(x) (int)(x).size() string guess_sequence(int N) { string p = ""; string S = ""; int a, b, x; a = b = x = 0; if(press("AB")){ if(press("A")) a = 1; else b = 1; } else{ if(press("X")) x = 1; } if(a) S = "A"; else if(b) S = "B"; else if(x) S = "X"; else S = "Y"; vector<string> choice; if(a) choice = {"B", "XX", "XB", "XY", "Y"}; else if(b) choice = {"A", "XX", "XA", "XY", "Y"}; else if(x) choice = {"A", "BB", "BA", "BY", "Y"}; else choice = {"A", "BB", "BA", "BX", "X"}; if(N == 1) return S; for(int i = 1; i < N - 1; ++i){ string to_press = ""; for(int j = 0; j < 4; ++j){ // cerr << S << ' ' << choice[j] << endl; to_press += S + choice[j]; } int len = press(to_press); if(len == sz(S)) S += choice.back(); else if(len == sz(S) + 1) S += choice.front().front(); else S += choice[1].front(); } if(press(S + choice[0]) == N) S += choice[0]; else if(press(S + choice[1][0]) == N) S += choice[1][0]; else S += choice.back(); return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...