Submission #991580

#TimeUsernameProblemLanguageResultExecution timeMemory
991580tosivanmakCombo (IOI18_combo)C++17
100 / 100
23 ms1364 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; #define ll long long std::string guess_sequence(int N) { int k=press("AB"); char c; if(k!=0){int s=press("A");if(s==0){c='B';}else{c='A';}} else{int s=press("X");if(s==0){c='Y';}else{c='X';}} int cnt=0; string cur="";cur+=c; set<char>st; st.insert('A'),st.insert('B'),st.insert('X'),st.insert('Y'); st.erase(c); char p[4]; p[1]=*st.begin();st.erase(*st.begin()); p[2]=*st.begin();st.erase(*st.begin()); p[3]=*st.begin();st.erase(*st.begin()); int i=1; for(;i<N-1;cnt++){ string tr=cur; tr+=p[1],tr+=p[2]; tr+=cur; tr+=p[1],tr+=p[3]; tr+=cur; tr+=p[2],tr+=p[2]; ll ans=press(tr); ll n=cur.length(); if(ans==n){ cur+=p[3]; i++; } else if(ans==n+1){ string dk=cur; dk+=p[2],dk+=p[3]; ll oo=press(dk); if(oo==n+2){cur+=p[2],cur+=p[3];} else if(oo==n+1){cur+=p[2],cur+=p[1];} else{cur+=p[1],cur+=p[1];} i+=2; } else{ string dk=cur; dk+=p[1],dk+=p[2]; ll oo=press(dk); if(oo==n+2){cur+=p[1],cur+=p[2];} else if(oo==n+1){cur+=p[1],cur+=p[3];} else{cur+=p[2],cur+=p[2];} i+=2; } } if(i==N){ return cur; } else{ string tr=cur;tr+=p[1]; if(press(tr)==N)return tr; tr[N-1]=p[2]; if(press(tr)==N)return tr; tr[N-1]=p[3]; return tr; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...