Submission #1189237

#TimeUsernameProblemLanguageResultExecution timeMemory
1189237Zakir060Combo (IOI18_combo)C++20
10 / 100
15 ms440 KiB
#include <string> #include <vector> #include <numeric> // Not strictly needed but good practice // Forward declaration or include header provided by contest environment // #include "combo.h" extern int press(std::string p); std::string guess_sequence(int N) { std::string guessed_S = ""; std::vector<char> all_chars = {'A', 'B', 'X', 'Y'}; if (N == 0) { return ""; } // --- Step 1: Determine the first character S[0] --- // Try A if (press("A") == 1) { guessed_S = "A"; } else if (press("B") == 1) { // Try B if A failed guessed_S = "B"; } else { // If A and B failed, try X // If press("X") == 1, it's X. Otherwise, it must be Y. if (press("X") == 1) { guessed_S = "X"; } else { guessed_S = "Y"; } } // --- Step 2: Determine the remaining characters S[1] to S[N-1] --- while (guessed_S.length() < N) { int k = guessed_S.length(); char next_char = 0; // To store the determined next character // Try appending 'A', 'B', 'X' one by one. // If press(current_guess + candidate) returns k+1, we found the next char. // If A, B, X don't work, the next char must be Y. if (press(guessed_S + 'A') == k + 1) { next_char = 'A'; } else if (press(guessed_S + 'B') == k + 1) { next_char = 'B'; } else if (press(guessed_S + 'X') == k + 1) { next_char = 'X'; } else { next_char = 'Y'; // Must be Y if others failed } // Append the determined character // Using push_back might be slightly more efficient than += for single chars guessed_S.push_back(next_char); } return guessed_S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...