Submission #762404

#TimeUsernameProblemLanguageResultExecution timeMemory
762404caganyanmazCombo (IOI18_combo)C++17
100 / 100
22 ms652 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; char characters[4] = {'A', 'B', 'X', 'Y'}; void find_and_replace_first_character() { string S(characters, 2); if (press(S) > 0) { S = string(characters, 1); if (press(S) == 0) swap(characters[0], characters[1]); } else { S = string(characters + 2, 1); if (press(S) > 0) swap(characters[0], characters[2]); else swap(characters[0], characters[3]); } } string guess_sequence(int n) { find_and_replace_first_character(); string S(characters, 1); if (n == 1) return S; for (int i = 1; i < n - 1; i++) { string query = S; query += characters[1]; for (int j = 1; j <= 3; j++) { query += S; query += characters[2]; query += characters[j]; } int res = press(query); if (res == i) S += characters[3]; else if (res == i+1) S += characters[1]; else if (res == i+2) S += characters[2]; else assert(false); } if (press(S + characters[1]) == n) return S + characters[1]; else if (press(S + characters[2]) == n) return S + characters[2]; else return S + characters[3]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...