Submission #604890

#TimeUsernameProblemLanguageResultExecution timeMemory
604890boris_mihovCombo (IOI18_combo)C++14
100 / 100
37 ms556 KiB
#include <iostream> #include "combo.h" char let[4] = {'A', 'B', 'X', 'Y'}; std::string ans, guess; std::string guess_sequence(int n) { int res = press("AB"), letIdx; if (res) { if (press("A")) ans = "A", letIdx = 0; else ans = "B", letIdx = 1; } else { if (press("X")) ans = "X", letIdx = 2; else ans = "Y", letIdx = 3; } if (n == 1) return ans; std::swap(let[letIdx], let[3]); for (int i = 2 ; i <= n-1 ; ++i) { guess = ans; guess += let[0]; guess += ans + let[1] + let[0]; guess += ans + let[1] + let[1]; guess += ans + let[1] + let[2]; int res = press(guess); if (res == i) ans += let[0]; if (res == i+1) ans += let[1]; if (res == i-1) ans += let[2]; } guess = ans + let[0]; if (press(guess) == n) return ans += let[0]; guess = ans + let[1]; if (press(guess) == n) return ans += let[1]; return ans += let[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...