Submission #596942

#TimeUsernameProblemLanguageResultExecution timeMemory
596942BelphegorCombo (IOI18_combo)C++14
100 / 100
35 ms600 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string C = "ABXY"; string guess_sequence(int n){ string s = "AB"; if(press(s)){ s = "A"; if(!press(s)) s = "B"; } else{ s = "X"; if(!press(s)) s = "Y"; } for(int i=0; C[i]; i++){ if(C[i]==s[0]){ C.erase(C.begin()+i); break; } } string S[4]; for(int i=0; i<4; i++) S[i] = s; n--; while(n){ int len = S[0].length(); if(n==1){ if(press(S[0]+"A"+S[0]+"B")>len){ if(press(S[0]+"A")>len) S[0].push_back('A'); else S[0].push_back('B'); } else{ if(press(S[0]+"X")>len) S[0].push_back('X'); else S[0].push_back('Y'); } } else{ for(int i=0; i<3; i++) S[i].push_back(C[0]); for(int i=0; i<3; i++) S[i].push_back(C[i]); S[3].push_back(C[1]); int ret = press(S[0]+S[1]+S[2]+S[3]); for(int i=0; i<3; i++){ S[i].pop_back(); S[i].pop_back(); } S[3].pop_back(); char ch; if(ret==len) ch = C[2]; else if(ret==len+1) ch = C[1]; else ch = C[0]; for(int i=0; i<4; i++) S[i].push_back(ch); } n--; } return S[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...