Submission #1029630

#TimeUsernameProblemLanguageResultExecution timeMemory
1029630DorostWefCombo (IOI18_combo)C++17
100 / 100
21 ms1792 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { int n = N; string t = "ABXY"; int a[4] = {}; int ww = 0; if (press ("AB")) { if (press ("A")) ww = 0; else ww = 1; } else { if (press ("X")) ww = 2; else ww = 3; } a[ww] = 1; string s; string tt; for (int i = 0; i < 4; i++) { if (a[i]) { s += t[i]; if (N == 1) return s; } else { tt += t[i]; } } for (int i = 1; i < n - 1; i++) { string g = s; g += tt[0]; g += s; g += tt[1]; g += tt[0]; g += s; g += tt[1]; g += tt[1]; g += s; g += tt[1]; g += tt[2]; int w = press (g); if (w == (int)s.size()) s += tt[2]; else if (w == (int)s.size() + 1) s += tt[0]; else if (w == (int)s.size() + 2) s += tt[1]; else { assert (false); } } string g = s; g += tt[0]; string gg = s; gg += tt[1]; string ggg = s; ggg += tt[2]; int w = press (g); int w2 = press (gg); if (w == n) { return g; } else if (w2 == n) { return gg; } else { return ggg; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...