# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671002 | Arixcrest | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
string fillseq(string s,int sz){
string temp = "";
while(temp.size()<sz){
temp+=s;
}
while(temp.size()>sz) temp.pop_back();
return temp;
}
string guess_sequence(int n){
n = 4*n;
int mx = 0;
string ans = "";
int v;
vector<char> vals = {'A','B','X','Y'};
int cnt =0;
while(mx!=n/4){
cnt++;
if(mx==0){
string temp1 = fillseq("A",n/2);
temp1+=fillseq("B",n/2);
v = press(temp1);
if(v>mx){
temp1 = fillseq("A",n);
v = press(temp1);
if(v>mx){
mx = v;
ans+="A";
}else{
ans+="B";
}
}else{
temp1 = fillseq("X",n);
v = press(temp1);
if(v>mx){
mx = v;
ans+='X';
}else{
mx = v;
ans+="Y";
}
}
for(auto it = vals.begin();it!=vals.end();it++){
if(*it==ans.front()){
vals.erase(it);
break;
}
}
}else{
if(mx==n/4-1){
string temp1 = ans+vals[0];
while(temp1.size()<n) temp1+=(ans.front());
v = press(temp1);
if(v-mx==1){
ans+=vals[0];
break;
}
temp1 = ans+vals[1];
while(temp1.size()<n) temp1+=(ans.front());
v = press(temp1);
if(v-mx==1){
ans+=vals[1];
break;
}else{
ans+=vals[2];
break;
}
}
else{
string temp1 = ans+vals[0]+vals[0];
temp1+=ans+vals[0]+vals[1];
temp1+=ans+vals[0]+vals[2];
temp1+=ans+vals[1];
while(temp1.size()<n) temp1+=(ans.front());
v = press(temp1);
if(v-mx==2){
ans+=vals[0];
}else if(v-mx==1){
ans+=vals[1];
}else{
ans+=(vals[2]);
}
mx++;
}
}
}
// cout<<cnt<<" "<<ans<<"\n";
return ans;
}