제출 #322085

#제출 시각아이디문제언어결과실행 시간메모리
322085kwongweng콤보 (IOI18_combo)C++14
100 / 100
52 ms644 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; /* string P = "AB"; int press(string S){ int maxi = 0; for (int i = 0; i < S.size(); i++){ int j = i, k = 0, cnt = 0; while (j < S.size() && k < P.size()){ if (S[j] != P[k]) break; cnt++; j++; k++; } maxi = max(maxi, cnt); } cout << S << " " << maxi << '\n'; return maxi; } */ string guess_sequence(int n){ string S = ""; int a = press("AB"); if (a >= 1){ int b = press("A"); if (b == 1){ S += "A"; }else{ S += "B"; } }else{ int b = press("X"); if (b == 1) S += "X"; else S += "Y"; } if (n == 1) return S; string c = "ABXY"; string ch = ""; for (int i = 0; i < 4; i++){ if (c[i] == S[0]) continue; ch += c[i]; } for (int i = 1; i < n-1; i++){ string ask = S + ch[0] + ch[0] + S + ch[0] + ch[1] + S + ch[0] + ch[2] + S + ch[1]; int b = press(ask); if (b == i) S += ch[2]; else if (b == i+1) S += ch[1]; else S += ch[0]; } int b = press(S + ch[0]); if (b == n) return S + ch[0]; int d = press(S + ch[1]); if (d == n) return S + ch[1]; else return S + ch[2]; } /* int main(){ int n = P.size(); string s = guess_sequence(n); cout << s << '\n'; if (s == P) cout << "YES\n"; else cout << "NO\n"; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...