Submission #791721

#TimeUsernameProblemLanguageResultExecution timeMemory
791721pavementCombo (IOI18_combo)C++17
100 / 100
32 ms676 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define pb push_back string guess_sequence(int N) { char st; int p = press("AB"); if (p) { p = press("A"); if (p) st = 'A'; else st = 'B'; } else { p = press("X"); if (p) st = 'X'; else st = 'Y'; } vector<char> valid; for (char c : {'A', 'B', 'X', 'Y'}) { if (c != st) valid.pb(c); } string s = ""; s.pb(st); if (N == 1) return s; for (int i = 1; i + 1 < N; i++) { string q = s; q.pb(valid[0]); q += s; q.pb(valid[1]); q.pb(valid[0]); q += s; q.pb(valid[1]); q.pb(valid[1]); q += s; q.pb(valid[1]); q.pb(valid[2]); int p = press(q); if (p == (int)s.size()) s.pb(valid[2]); else if (p == (int)s.size() + 1) s.pb(valid[0]); else s.pb(valid[1]); } p = press(s + valid[0] + s + valid[1]); if (p == (int)s.size() + 1) { p = press(s + valid[0]); if (p == (int)s.size() + 1) s += valid[0]; else s += valid[1]; } else { s += valid[2]; } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...