Submission #439429

#TimeUsernameProblemLanguageResultExecution timeMemory
439429DecapitatedOCombo (IOI18_combo)C++17
97 / 100
41 ms640 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; vector<char> letters = {'A', 'B', 'X', 'Y'}; string guess_sequence(int N) { string p = ""; int coins; // Find first character for (int i = 0; i < (int) letters.size() - 1; i++) { if ((coins = press(p + letters[i])) > 0) { p += letters[i]; letters.erase(letters.begin() + i); break; } } if ((int) p.size() == 0) { p += letters[letters.size() - 1]; letters.pop_back(); } if (N == 1) return p; // Find characters 2...N-1 for (int i = 2; i <= N - 1; i++) { string guess = p + letters[0] + p + letters[1] + letters[0] + p + letters[1] + letters[1] + p + letters[1] + letters[2]; coins = press(guess) - p.size(); switch (coins) { case 0: p += letters[2]; break; case 1: p += letters[0]; break; case 2: p += letters[1]; break; } } // Find last character for (int i = 0; i < (int) letters.size() - 1; i++) { if ((coins = press(p + letters[i])) == N) { p += letters[i]; letters.erase(letters.begin() + i); break; } } if ((int) p.size() == N - 1) { p += letters[letters.size() - 1]; } string S = p; return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...