Submission #246994

#TimeUsernameProblemLanguageResultExecution timeMemory
246994ernestvwCombo (IOI18_combo)C++17
100 / 100
44 ms824 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) ((int)x.size()) int press(string p); char find_first() { int q1 = press("AB"); if(q1 > 0) { int q2 = press("A"); if(q2 > 0) return 'A'; return 'B'; } int q2 = press("X"); if(q2 > 0) return 'X'; return 'Y'; } string guess_sequence(int N) { string ans = ""; char premier = find_first(); ans += premier; vector<char> C; if('A' != premier) C.push_back('A'); if('B' != premier) C.push_back('B'); if('X' != premier) C.push_back('X'); if('Y' != premier) C.push_back('Y'); vector<string> D; for(char c1 : C) for(char c2 : C) { string p = ""; p += c1; p += c2; D.push_back(p); } for(int i = 1; i < N - 1; ++i) { string p = ""; vector<string> q(4, ans); for(int j = 0; j < 3; ++j) { q[j] += C[0]; q[j] += C[j]; } q[3] += C[1]; for(string s : q) p += s; int x = press(p); if(x == i + 2) ans += C[0]; else if(x == i + 1) ans += C[1]; else ans += C[2]; } if(N == 1) return ans; string p1 = ans; p1 += C[0]; p1 += ans; p1 += C[1]; int x = press(p1); if(x == N) { string p2 = ans; p2 += C[0]; int y = press(p2); if(y == N) ans += C[0]; else ans += C[1]; } else ans += C[2]; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...