Submission #567600

#TimeUsernameProblemLanguageResultExecution timeMemory
567600valerikkCombo (IOI18_combo)C++17
97 / 100
43 ms556 KiB
#include "combo.h" #include <vector> #include <string> #include <algorithm> #include <assert.h> #include <iostream> std::string guess_sequence(int N) { std::vector<char> buttons = { 'A', 'B', 'X', 'Y' }; int first = 0; while (first < 3 && press({ buttons[first] }) == 0) { ++first; } char Y = buttons[first]; char A = buttons[(first + 1) % 4]; char B = buttons[(first + 2) % 4]; char X = buttons[(first + 3) % 4]; std::string S = { Y }; while ((int) S.size() < N - 1) { std::string p = S + A + A + S + A + B + S + A + X + S + B; // std::cerr << S << " " << p << "\n"; int coins = press(p); int matching = coins - (int) S.size(); if (matching == 0) { S += X; } else if (matching == 1) { S += B; } else { S += A; } } if ((int) S.size() < N) { if (press(S + A) == N) { S += A; } else if (press(S + B) == N) { S += B; } else { S += X; } } std::cerr << S << "\n"; return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...