# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1185766 | Mamikonm1 | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include<bits//stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string s;
vector<pair<int,char>>x({{0,'A'},{0,'B'},{0,'X'},{0,'Y'});
set<string>st;
int mx=0,cur;
for(;;){
bool ok=0;
sort(rbegin(x),rend(x));
for(auto& j:x){
s+=j.second;
if(!st.count(s)){
cur=press(s);
if(cur>mx){
mx=cur;
j.first++;
ok=1;
break;
}
st.insert(s);
}
s.pop_back();
}
if(!ok or s.size()==N)break;
}
for(;s.size()!=N;){
bool ok=0;
sort(rbegin(x),rend(x));
for(auto& j:x){
s=j.second+s;
if(!st.count(s)){
cur=press(s);
if(cur>mx){
mx=cur;
ok=1;
j.first++;
break;
}
st.insert(s);
}
reverse(begin(s),end(s));
s.pop_back();
reverse(begin(s),end(s));
}
if(!ok)break;
}
return s;
}