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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string ans = "";
int a=press("AB"),b;
unordered_set<char> poss {'A','B','X','Y'};
if(a){
int b=press("B");
if(b){
ans+="B";
poss.erase('B');
}else{
ans+="A";
poss.erase('A');
}
}else{
int y=press("Y");
if(y){
ans+="Y";
poss.erase('Y');
}else{
ans+="X";
poss.erase('X');
}
}
// printf("%d\n",poss.size());
for(int x=1;x<N-1;x++){
int temp=0;
string qu = "";
auto it = poss.begin();
qu+=ans + *it;
for(char c:poss){
qu+=ans+*next(it)+c;
}
//printf("%c %c %c\n",*next(it),*it,*next(next(it)));
//printf("%s\n",qu.c_str());
int coins=press(qu);
//printf("%s %d %d\n",qu.c_str(),coins,(int)ans.size());
// if(x==2)
// return 0;
if(coins==(int)ans.size())
ans+=*next(next(it));
else if(coins==2+(int)ans.size()){
ans+=*next(it);
}else
ans+=*it;
}
if(N>=2){
a=press(ans+*poss.begin()),b=press(ans+*next(poss.begin()));
if(a==N)
ans+=*poss.begin();
else if(b==N)
ans+=*next(poss.begin());
else
ans+=*next(next(poss.begin()));
//cout<<ans;
}
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:13: warning: unused variable 'temp' [-Wunused-variable]
31 | int temp=0;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |