Submission #477061

#TimeUsernameProblemLanguageResultExecution timeMemory
477061Genius3435Combo (IOI18_combo)C++17
100 / 100
37 ms528 KiB
#include "combo.h" #include <algorithm> #include <string> std::string guess_sequence(int N) { std::string cur; if (press("AB")) { if (press("A")) cur = "A"; else cur = "B"; } else { if (press("X")) cur = "X"; else cur = "Y"; } std::string poss = "ABXY"; poss.erase(poss.find(cur[0]), 1); const char A = poss[0], B = poss[1], X = poss[2]; while ((int) cur.size()+2 <= N) { // Let s = cur, A,B,X = poss // Try sAA + sAB + sBA int p = press(cur+A+A + cur+A+B + cur+B+A); const int sz = cur.size(); if (p == sz) { // Next char is X cur += X; } else if (p == sz+1) { // Next chars are AX,BB,BX p = press(cur+B+B); if (p == sz+2) cur += B, cur += B; else if (p == sz+1) cur += B, cur += X; else cur += A, cur += X; } else { // Next chars are AA,AB,BA p = press(cur+A+A); if (p == sz+2) cur += A, cur += A; else if (p == sz+1) cur += A, cur += B; else cur += B, cur += A; } } if (N == (int) cur.size()) return cur; if (press(cur+A) == N) return cur+A; else if (press(cur+B) == N) return cur+B; else return cur+X; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...