Submission #112751

#TimeUsernameProblemLanguageResultExecution timeMemory
112751fredbrCombo (IOI18_combo)C++17
100 / 100
57 ms552 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string first_guess() { static string t1("AB"); int ans = press(t1); if (ans) { if (press("A")) return "A"; else return "B"; } else { if (press("X")) return "X"; else return "Y"; } } string guess_sequence(int n) { string ans = first_guess(); if (n == 1) return ans; string f = ans; vector<string> poss; for (string a : {"A", "B", "X", "Y"}) { if (a != f) poss.push_back(a); } vector<string> comb = {poss[0]+poss[0], poss[0]+poss[1], poss[0]+poss[2], poss[1]}; for (int i = 1; i < n-1; i++) { string tmpans = ans + comb[0] + ans + comb[1] + ans + comb[2] + ans + comb[3]; int x = press(tmpans); switch (x-i) { case 2: ans += poss[0]; break; case 1: ans += poss[1]; break; case 0: ans += poss[2]; break; } } ans += poss[0]; if (press(ans) == n) { return ans; } ans.pop_back(); ans += poss[1]; if (press(ans) == n) { return ans; } ans.pop_back(); ans += poss[2]; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...