제출 #295498

#제출 시각아이디문제언어결과실행 시간메모리
295498arayi콤보 (IOI18_combo)C++17
100 / 100
35 ms568 KiB
#include "combo.h" #include <iostream> #include <string> #include <vector> #include <algorithm> #define ad push_back using namespace std; string ans; vector <char> a; void frst() { int sm = press("AB"); if (sm == 2) { ans = "AB"; a.ad('B'), a.ad('X'), a.ad('Y'); return; } if (sm == 1) { sm = press("A"); if (sm) ans = "A", a.ad('B'), a.ad('X'), a.ad('Y'); else ans = "B", a.ad('A'), a.ad('X'), a.ad('Y'); return; } if (sm == 0) { sm = press("X"); if (sm) ans = "X", a.ad('B'), a.ad('A'), a.ad('Y'); else ans = "Y", a.ad('B'), a.ad('X'), a.ad('A'); return; } } string guess_sequence(int n) { frst(); string p; while ((int)ans.length() <= n - 2) { p = ""; p += ans + a[0] + a[0]; p += ans + a[0] + a[1]; p += ans + a[1] + a[1]; int sm = press(p); if (sm == (int)ans.length()) { ans += a[2]; } else if (sm == 2 + (int)ans.length()) { p = ""; p += ans + a[0] + a[0]; sm = press(p); if (sm == (int)ans.length()) ans += a[1], ans += a[1]; else if (sm == (int)ans.length() + 1) ans += a[0], ans += a[1]; else ans += a[0], ans += a[0]; } else { p = ""; p += ans + a[1] + a[0]; sm = press(p); if (sm == (int)ans.length()) ans += a[0], ans += a[2]; else if (sm == (int)ans.length() + 1) ans += a[1], ans += a[2]; else ans += a[1], ans += a[0]; } } if ((int)ans.length() == n - 1) { p = ""; p += ans + a[0]; p += ans + a[1]; int sm = press(p); if (sm == (int)ans.length()) ans += a[2]; else { p = ans + a[0]; sm = press(p); if (sm == (int)ans.length() + 1) ans += a[0]; else ans += a[1]; } } // cout << ans << endl; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...