Submission #331620

#TimeUsernameProblemLanguageResultExecution timeMemory
331620FalconCombo (IOI18_combo)C++17
100 / 100
45 ms748 KiB
#include "combo.h" #include <iostream> #include <cassert> std::string guess_sequence(int N) { std::string p = ""; if(press("AB")) p = press("A") ? "A" : "B"; else p = press("X") ? "X" : "Y"; if(N == 1) return p; std::string chars = ""; for(const char c : std::string("ABXY")) if(c && c != p[0]) chars += c; assert(int(chars.size()) == 3); for(int i = 1; i < N - 1; ++i) { assert(int(p.size()) == i); std::string a, b, c, d; a = p + chars[0]; b = p + chars[1] + chars[0]; c = p + chars[1] + chars[1]; d = p + chars[1] + chars[2]; switch(press(a + b + c + d) - i) { case 0: p += chars[2]; break; case 1: p += chars[0]; break; case 2: p += chars[1]; break; default: std::cout << p << ' ' << press(a + b + c + d) << ' ' << i << '\n'; assert(0); } } assert(int(p.size()) == N - 1); for(const char c : chars) if(c != chars[0] && press(p + c) == N) { p += c; break; } if(int(p.size()) == N - 1) p += chars[0]; assert(int(p.size()) == N); return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...