Submission #281682

#TimeUsernameProblemLanguageResultExecution timeMemory
281682MrDominoCombo (IOI18_combo)C++14
30 / 100
78 ms656 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string del(string s, char ch) { string t; for (auto &x : s) { if (x != ch) { t += x; } } return t; } mt19937 rng((long long) (new char)); string mult(char ch, int x) { string s; for (int i = 1; i <= x; i++) { s += ch; } return s; } string guess_sequence(int n) { string sol; string posi = "ABXY"; bool found = 0; for (int j = 0; j < 3; j++) { if (press(sol + posi[j]) == 1) { found = 1; sol += posi[j]; break; } } if (found == 0) { sol += posi[3]; } posi = del(posi, sol[0]); while ((int) sol.size() + 1 <= n) { shuffle(posi.begin(), posi.end(), rng); char a = posi[0]; char b = posi[1]; char c = posi[2]; int ret = press(sol + mult(a, n) + sol + mult(b, n)); if (ret == (int) sol.size()) { sol += c; continue; } if (ret == n) { if (press(sol + mult(a, n)) == n) { sol += mult(a, n - (int) sol.size()); } else { sol += mult(b, n - (int) sol.size()); } continue; } /// aaaaaaaab /// aaaaaaaac /// bbbbbbbba /// bbbbbbbbc int ret2 = press(sol + mult(a, ret - (int) sol.size()) + mult(b, n)); if (ret2 > ret) { sol += mult(a, ret - (int) sol.size()) + mult(b, ret2 - ret); continue; } if (ret2 == ret) { sol += mult(a, ret - (int) sol.size()) + c; continue; } int ret3 = press(sol + mult(b, ret - (int) sol.size()) + mult(a, n)); if (ret3 > ret2) { sol += mult(b, ret - (int) sol.size()) + mult(a, ret3 - ret); } else { sol += mult(b, ret - (int) sol.size()) + c; } } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...