제출 #807809

#제출 시각아이디문제언어결과실행 시간메모리
807809math_rabbit_1028콤보 (IOI18_combo)C++14
100 / 100
34 ms500 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; int n; string solve(string s, string t, string u, string v) { string ans, query; ans = s; for (int i = 2; i < n; i++) { query = ""; query += ans; query += t; query += t; query += ans; query += t; query += u; query += ans; query += t; query += v; query += ans; query += u; int res = press(query); if (res == i + 1) ans += t; if (res == i) ans += u; if (res == i - 1) ans += v; } query = ans + t; if (press(query) == n) return query; query = ans + u; if (press(query) == n) return query; query = ans + v; return query; } std::string guess_sequence(int N) { n = N; int ab = press("AB"); if (ab) { int a = press("A"); if (a == 1) { if (n == 1) return "A"; return solve("A", "B", "X", "Y"); } else { if (n == 1) return "B"; return solve("B", "A", "X", "Y"); } } else { int x = press("X"); if (x == 1) { if (n == 1) return "X"; return solve("X", "A", "B", "Y"); } else { if (n == 1) return "Y"; return solve("Y", "A", "B", "X"); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...