Submission #1278565

#TimeUsernameProblemLanguageResultExecution timeMemory
1278565mm2302Combo (IOI18_combo)C++20
0 / 100
1 ms332 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n){ string s; if(press("AB")==0){ if(press("X")==0) s="Y"; else s="X"; } else { if(press("A")==0) s="B"; else s="A"; } if(n==1) return s; string hgh="ABXY"; char combi, other, last; int var=0; for(int i=0;i<4;i++){ if(hgh[i]!=s[0]){ if(var==0) {combi=hgh[i]; var++;} else if(var==1){other=hgh[i]; var++;} else last=hgh[i]; } } int cnt=1; while(true){ if(s.length()==n-1){ if(press(s+combi)==0){ if(press(s+other)==0) return s+last; else return s+other; } else { return s+combi; } } int result=press(s+combi+combi+s+combi+other+s+combi+last+s+other); if(result-cnt==1){ s+=last; } else if(result-cnt==2){ s+=other; } else if(result-cnt==3){ s+=combi; } cnt++; if(s.length()==n-1) break; } if(press(s+combi)==n) return s+combi; else if(press(s+other)==n) return s+other; else return s+last; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...