Submission #573113

#TimeUsernameProblemLanguageResultExecution timeMemory
573113dnialhCombo (IOI18_combo)C++17
100 / 100
29 ms604 KiB
#include "combo.h" #include <vector> using namespace std; string guess_sequence(int N) { string p = "AB"; int coins = press(p); string start; if (coins){ string q = "A"; coins = press(q); if (coins){ start = "A"; } else { start = "B"; } } else { string q = "X"; coins = press(q); if (coins){ start = "X"; } else { start = "Y"; } } if (N == 1) return start; vector<string> other; if (start != "A"){ other.push_back("A"); } if (start != "B"){ other.push_back("B"); } if (start != "X"){ other.push_back("X"); } if (start != "Y"){ other.push_back("Y"); } string S = start; for (int i = 1; i < N - 1; ++i) { string query = S + other[1]; query += (S + other[2] + other[0]); query += (S + other[2] + other[1]); query += (S + other[2] + other[2]); int res = press(query); S += other[res - i]; } int r1 = press(S + other[0]); if (r1 == N){ return S + other[0]; } int r2 = press(S + other[1]); if (r2 == N){ return S + other[1]; } return S + other[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...