Submission #274678

#TimeUsernameProblemLanguageResultExecution timeMemory
274678Haunted_CppCombo (IOI18_combo)C++17
100 / 100
42 ms712 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { vector<char> letter = {'A', 'B', 'X', 'Y'}; char first_one; int s = press("AB"); if (s) { s = press("A"); if (s == 0) first_one = 'B'; else first_one = 'A'; } else { s = press("X"); if (s == 0) first_one = 'Y'; else first_one = 'X'; } letter.erase(find(letter.begin(), letter.end(), first_one)); string S; S += first_one; if (N == 1) { return S; } for (int i = 1; i < N - 1; i++) { string guess = S + letter[0]; guess += S + letter[1] + letter[1]; guess += S + letter[1] + letter[0]; guess += S + letter[1] + letter[2]; int score = press(guess); if (score == i + 1) { S += letter[0]; } else if (score == i + 2) { S += letter[1]; } else { S += letter[2]; } } string guess = S + letter[0]; if (press(guess) == N) { return guess; } guess = S + letter[1]; if (press(guess) == N) { return guess; } guess = S + letter[2]; return guess; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...