Submission #256342

#TimeUsernameProblemLanguageResultExecution timeMemory
256342SpeedOfMagicCombo (IOI18_combo)C++17
100 / 100
36 ms548 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define sz(a) (int) a.size() string guess_sequence(int N) { string ans = ""; string l1 = "A", l2 = "B", l3 = "X"; int c = press("AB"); if (c) { c = press("A"); if (c) { ans += "A"; l1 = "Y"; } else { ans += "B"; l2 = "Y"; } } else { c = press("X"); if (c) { ans += "X"; l3 = "Y"; } else ans += "Y"; } while (sz(ans) < N) { if (sz(ans) + 1 == N) { string v = ans + l1 + ans + l2; //cout << v << endl; c = press(v) - sz(ans); if (c) { v = ans + l1; //cout << v << endl; c = press(v) - sz(ans); if (c) ans += l1; else ans += l2; } else ans += l3; } else { string v = ans + l1 + l1 + ans + l1 + l2 + ans + l2 + l1; //cout << v << endl; c = press(v) - sz(ans); if (c == 0) ans += l3; else if (c == 1) { string v = ans + l2 + l2; //cout << v << endl; c = press(v) - sz(ans); if (c == 0) ans += l1 + l3; else if (c == 1) ans += l2 + l3; else ans += l2 + l2; } else { string v = ans + l1 + l1; //cout << v << endl; c = press(v) - sz(ans); if (c == 0) ans += l2 + l1; else if (c == 1) ans += l1 + l2; else ans += l1 + l1; } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...