제출 #132787

#제출 시각아이디문제언어결과실행 시간메모리
132787WLZ콤보 (IOI18_combo)C++14
5 / 100
3 ms256 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ans = ""; if (press("AB") >= 1) { if (press("A")) { ans = "A"; } else { ans = "B"; } } else { if (press("X")) { ans = "X"; } else { ans = "Y"; } } set<char> st = {'A', 'B', 'X', 'Y'}; for (auto& c : st) { if (ans[0] == c) { st.erase(c); break; } } for (int i = 1; i < N - 1; i++) { string guess = ans + *st.begin(); for (auto& c : st) { guess += ans + *prev(st.end()) + c; } int tmp = press(guess); if (tmp == (int) ans.length()) { ans += *next(st.begin()); } else if (tmp == (int) ans.length() + 1) { ans += *st.begin(); } else { ans += *prev(st.end()); } } if (press(ans + *st.begin()) == N) { ans += *st.begin(); } else if (press(ans + *next(st.begin())) == N) { ans += *next(st.begin()); } else { ans += *prev(st.end()); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...