# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491338 | cosmic | 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;
char buttons[4]={'A','B','X','Y'};
char firstch;
char next(char w){
int first=-1;
for(int i=0;i<4;i++){
if(buttons[i]==firstch) first=i;
}
return next((first+w)%4);
}
std::string guess_sequence(int N) {
/* std::string p = "";
for (int i = 0; i < 4 * N; ++i) {
p += 'A';
}
int coins = press(p);
std::string S = "";
for (int i = 0; i < N; ++i) {
S += 'A';
}*/
string s=" ";
if(press("AB")>=1){
if(press("A")==1){
s+="A";
}else s+="B";
}else{
if(press("X")==1) s+="X";
else s+="Y";
}
firstch=s[0];
while((int)s.size()<N-1){
string quer=s+next(1);
quer+=s+next(2)+next(1);
quer+=s+next(2)+next(2);
quer+=s+next(2)+next(3);
int x=press(quer);
if(x==s.size()+1) s+=next(3);
else if(x==s.size()+2) s+=next(1);
else s+=next(2);
}
if(press(s+next(1))==N) s+=next(1);
else if(press(s+next(2))==N) s+=next(2);
else s+=next(3);
return N;
}