Submission #434091

#TimeUsernameProblemLanguageResultExecution timeMemory
434091Tiago_MarquesCombo (IOI18_combo)C++17
5 / 100
6 ms200 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string s, p; char option[4] = {'A', 'B', 'X', 'Y'}; int x; p = "AB"; x = press(p); if (x) { p = "A"; x = press(p); if (x) { s = "A"; } else { s = "B"; swap (option[0], option[1]); } } else { p = "X"; x = press(p); if (x) { s = "X"; swap (option[0], option[2]); } else { s = "Y"; swap (option[0], option[3]); } } while ((int)s.size() < N - 1) { p.clear(); p += s; p += option[1]; p += option[1]; p += s; p += option[1]; p += option[2]; p += s; p += option[1]; p += option[3]; p += s; p += option[2]; p += option[0]; x = press (p); if (x == (int)s.size()) { s += option[3]; } if (x == (int)s.size() + 1) { s += option[2]; } if (x == (int)s.size() + 2) { s += option[1]; } } s += option[1]; if (press (s) == N) return s; s .pop_back(); s += option[2]; if (press(s) == N) return s; s.pop_back(); s += option[3]; return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...