Submission #583666

#TimeUsernameProblemLanguageResultExecution timeMemory
583666Mystic03Combo (IOI18_combo)C++17
100 / 100
40 ms536 KiB
#include "combo.h" #include <vector> #include <algorithm> #include <string> using namespace std; std::string guess_sequence(int N) { string s = ""; vector<char> rem{ 'A', 'B', 'X', 'Y' }; if (press("AB")) { if (press("A")) { s.push_back('A'); } else s.push_back('B'); } else { if (press("X")) { s.push_back('X'); } else s.push_back('Y'); } if (N == 1) return s; rem.erase(find(rem.begin(), rem.end(), s[0])); for (int i = 1; i < N - 1; i++) { int len = s.size(); string check = s; check.push_back(rem[0]); check.push_back(rem[0]); check += s; check.push_back(rem[0]); check.push_back(rem[1]); check += s; check.push_back(rem[0]); check.push_back(rem[2]); check += s; check.push_back(rem[2]); int newLen = press(check); if (newLen == len + 2) s.push_back(rem[0]); else if (newLen == len + 1) s.push_back(rem[2]); else s.push_back(rem[1]); } string finalAns = s; finalAns.push_back(rem[0]); if (press(finalAns) > (int)s.length()) { return finalAns; } finalAns.pop_back(); finalAns.push_back(rem[1]); if (press(finalAns) > (int)s.length()) { return finalAns; } finalAns.pop_back(); finalAns.push_back(rem[2]); return finalAns; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...