제출 #536410

#제출 시각아이디문제언어결과실행 시간메모리
536410fuad27콤보 (IOI18_combo)C++17
100 / 100
34 ms596 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; char keys[] = {'A','B','X','Y'}; string B = "", X ="", Y =""; vector<char> keys2; char next_char(string s) { B = "", X ="", Y =""; B.push_back(keys2[0]); X.push_back(keys2[1]); Y.push_back(keys2[2]); string ask = s+B + s + X + B + s + X + X + s + X + Y; int val = press(ask) - s.size(); if(val == 1)return B[0]; else if(val == 2)return X[0]; return Y[0]; } string guess_sequence(int n) { string p = ""; if(press("AB")) { if(press("A"))p = "A"; else p = "B"; } else { if(press("X"))p = "X"; else p = "Y"; } if(n == 1)return p; char start = p[0]; for(int i = 0;i<4;i++) { if(keys[i] == start)continue; keys2.push_back(keys[i]); } for(int j = 1;j<n-1;j++) { char c = next_char(p); p.push_back(c); } for(int i = 0;i<2;i++) { p.push_back(keys2[i]); if(press(p) == n) { break; } p.pop_back(); } if((int)p.size()!=n) { p.push_back(keys2[2]); } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...