제출 #581785

#제출 시각아이디문제언어결과실행 시간메모리
581785ddy888콤보 (IOI18_combo)C++17
100 / 100
40 ms628 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second typedef pair<int,int> pi; void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) string ans; string ch = "ABXY"; char rem[4]; int id; string guess_sequence(int n) { int f = press("AB"); if (f) { if (press("A")) ans += "A"; else ans += "B"; } else { if (press("X")) ans += "X"; else ans += "Y"; } for (int i = 0; i < 4; ++i) { if (ch[i] != ans[0]) { rem[++id] = ch[i]; } } rem[0] = rem[id]; if (n == 1) return ans; if (n == 2) goto last; for (int i = 2; i < n; ++i) { string guess = ""; int cnt = 0; for (int j = 0; j < 4; ++j) { if (ans[0] == ch[j]) continue; ++cnt; if (cnt == 1) { guess += ans + ch[j]; } else { for (int k = 0; k < 4; ++k) { if (ans[0] == ch[k]) continue; guess += ans + ch[j] + ch[k]; } break; } } int res = press(guess) - (int)ans.size(); ans += rem[res]; } last: for (int i = 0; i < 2; ++i) { string guess = ans + rem[i]; if (press(guess) == n) return guess; } ans += rem[2]; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...