# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
276024 | Bill_00 | Combo (IOI18_combo) | C++14 | 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.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int n){
int p=press("AB");
char k;
vector<char>a;
a.push_back('A');
a.push_back('B');
a.push_back('X');
a.push_back('Y');
string ans;
if(p==0){
p=press("X");
if(p==0){
k='Y';
}
else k='X';
}
else{
p=press("A");
if(p==0){
k='B';
}
else k='A';
}
ans+=k;
for(int i=0;i<4;i++){
if(a[i]==k){
a.erase(a.begin()+i);
}
}
for(int i=2;i<n;i++){
string g=ans+a[0]+a[0]+ans+a[0]+a[1]+ans+a[0]+a[2]+ans+a[1];
p=press(g);
if(p==ans.size()){
ans+=a[2];
}
else{
if(p==ans.size()+1){
ans+=a[1];
}
else ans+=a[0];
}
}
string g=ans+'A'+ans+'B'
p=press(g);
if(p==ans.size()){
p=press(ans+'X');
if(p==ans.size()){
return ans+'Y';
}
else return ans+'X';
}
else{
g=ans+'A';
p=press(g);
if(p==ans.size()){
return ans+'B';
}
else return ans+'A';
}
}