# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
574976 | Hackapie | 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.
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N){
set<char> s;
s.insert('A');
s.insert('B');
s.insert('X');
s.insert('Y');
string res;
int N;
cin>>N;
string check;
for(int i=1;i<=N;i++){ //cout<<"i:"<<i<<"\n";
//each i for ith character
//in first i we have 4 choices
//afterthat we have 3 choices always
char c;
if(i==1){
for(auto x:s){
string aux=res;
aux+=x;
int ans=press(aux);
// cout<<aux<<"\n";
// int ans;
// cin>>ans;
if(ans==i){
//ok this is part of the string
res=aux;
c=x;
break;
}
}
if(i==1)s.erase(c);
for(auto x:s)check+=x;
// cout<<"pr.size():"<<pr.size()<<"\n";
// for(int i=0;i<pr.size();i++){
// cout<<pr[i]<<" ";
// } cout<<"\n";
}else{
if(i==N){
for(auto x:s){
string aux=res;
aux+=x;
int ans=press(aux);
// cout<<aux<<"\n";
// int ans;
// cin>>ans;
if(ans==i){
//ok this is part of the string
res=aux;
break;
}
}
}else{
string ch=res+check[1]+res+check[2]+check[0]+res+check[2]+check[1]+res+check[2]+check[2];
res+=check[press(ch)-res.size()]; //we are not providing any res+check[0] in query so if 0th then always return 0 similarly we are provinging only next charcater for check[1] so if true always return 1 more and similarly we are providing all possibility of 2nd check so it will always return 2 more if present
}
}
}
return res;
}