Submission #645574

#TimeUsernameProblemLanguageResultExecution timeMemory
645574NursikCombo (IOI18_combo)C++14
100 / 100
40 ms572 KiB
#include "combo.h" #include <random> #include <iostream> #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const ll maxn = 2e3 + 1; vector<char> v = {'A', 'B', 'X', 'Y'}; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); string guess_sequence(int n) { string pref = ""; int get = press("AB"); if (get > 0){ get = press("A"); if (get == 1){ pref += "A"; } else{ pref += "B"; } } else{ get = press("X"); if (get == 1){ pref += "X"; } else{ pref += "Y"; } } vector<char> v2; for (auto it : v){ if (it != pref[0]){ v2.pb(it); } } for (int i = 2; i <= n; ){ if (i == n){ string npref = pref + v2[0] + pref + v2[1]; get = press(npref) - i + 1; if (get == 1){ npref = pref + v2[0]; get = press(npref) - i + 1; if (get == 1){ pref += v2[0]; } else{ pref += v2[1]; } } else{ pref += v2[2]; } break; } string npref = pref + v2[0] + v2[0] + pref + v2[1] + v2[1] + pref + v2[0] + v2[1]; get = press(npref); int kol = get - i + 1; if (kol == 2){ npref = pref + v2[0] + v2[0]; get = press(npref); int kol2 = get - i + 1; if (kol2 == 2){ pref += v2[0]; pref += v2[0]; i += 1; i += 1; } else if (kol2 == 1){ pref += v2[0]; pref += v2[1]; i += 1; i += 1; } else{ pref += v2[1]; pref += v2[1]; i += 1; i += 1; } } else if (kol == 1){ npref = pref + v2[1] + v2[2]; get = press(npref); int kol2 = get - i + 1; if (kol2 == 2){ pref += v2[1]; pref += v2[2]; i += 1; i += 1; } else if (kol2 == 1){ pref += v2[1]; pref += v2[0]; i += 1; i += 1; } else{ pref += v2[0]; pref += v2[2]; i += 1; i += 1; } } else{ pref += v2[2]; i += 1; } } return pref; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...