| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1322331 | aritro_ | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
int press(string p);
string guess_sequence(int n){
string ans="";
int cur=1;
if(press("A")==1) ans+="A";
else if(press("B")==1) ans+="B";
else if(press("X")==1) ans+="X";
else ans+="Y";
char f=ans[0];
string op;
if(f=='A') op="BXY";
if(f=='B') op="AXY";
if(f=='X') op="ABY";
if(f=='Y') op="ABX";
while(cur+1!=n){
int tem=press(ans+op[0]+ans+op[1]+op[0]+ans+op[1]+op[1]+ans+op[1]+op[2]);
if(tem==cur) ans+=op[2];
if(tem==cur+1) ans+=op[0];
if(tem==cur+2) ans+=op[1];
cur++;
}
if(press(ans+op[0])==n) ans+=op[0];
else if(press(ans+op[1])==n) ans+=op[1];
else ans+=op[2];
return ans;
}
int call=0;
string s;
int press(string p){
call++;
int ans=0;
for(int i=1;i<=(int)s.size();i++){
string pref=s.substr(0,i);
if(p.find(pref)!=string::npos) ans=i;
else break;
}
return ans;
}
void solve(){
cin>>s;
cout<<guess_sequence(s.size())<<endl;
cout<<call<<endl;
return;
}
int32_t main(){
solve();
return 0;
}
