Submission #766891

#TimeUsernameProblemLanguageResultExecution timeMemory
766891simeneCombo (IOI18_combo)C++14
100 / 100
26 ms580 KiB
#include "combo.h" using namespace std; string guess_sequence(int N) { string S = ""; string chrs; switch (press("AB")) { case 1: if (press("A")) { S = "A"; chrs = "BXY"; } else { S = "B"; chrs = "AXY"; } break; case 2: S = "AB"; chrs = "BXY"; break; default: if (press("X")) { S = "X"; chrs = "ABY"; } else { S = "Y"; chrs = "ABX"; } break; } int len = S.size(); while (len < N - 1) { string query = S + chrs[0] + S + chrs[1] + chrs[0] + S + chrs[1] + chrs[1] + S + chrs[1] + chrs[2]; int res = press(query); if (res == len) { S += chrs[2]; } else if (res == len + 1) { S += chrs[0]; } else { S += chrs[1]; } len++; } if (len != N) { if (press(S + chrs[0]) == len + 1) return S + chrs[0]; else if (press(S + chrs[1]) == len + 1) return S + chrs[1]; else return S + chrs[2]; } return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...