Submission #772977

#TimeUsernameProblemLanguageResultExecution timeMemory
772977AlanCombo (IOI18_combo)C++17
100 / 100
27 ms588 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string s = "AB", t, d; int res = press(s); if (res) { s = "A"; res = press(s); t = res ? "A" : "B"; } else { s = "X"; res = press(s); t = res ? "X" : "Y"; } if (N == 1) return t; for (auto& x : {'A', 'B', 'X', 'Y'}) if (x != t[0]) d.push_back(x); for (int i = 1; i < N-1; i++) { s = t; s.push_back(d[0]); s += t; s.push_back(d[1]); s.push_back(d[0]); s += t; s.push_back(d[1]); s.push_back(d[1]); s += t; s.push_back(d[1]); s.push_back(d[2]); res = press(s); if (res <= i) t.push_back(d[2]); else if (res == i+1) t.push_back(d[0]); else t.push_back(d[1]); } for (int i = 0; i < 2; i++) { s = t; s.push_back(d[i]); res = press(s); if (res == N) { t.push_back(d[i]); break; } } if ((int) t.size() < N) t.push_back(d[2]); return t; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...