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) {
string str="",qry="AB";
vector<char>all;
char C[4]={'A','B','X','Y'};
int l=press(qry);
if (l>=1){
qry.pop_back();
l=press(qry);
if (l==1) str="A";
else str="B";
}
else {
qry="X"; l=press(qry);
if (l==1) str="X";
else str="Y";
}
if (N==1) return str;
for (int i=0;i<4;i++){
if (str[0]!=C[i])
all.push_back(C[i]);
}
int last=1;
for (int i=2;i<N;i++){
qry=str+all[0]+all[0]+str+all[0]+all[1]+str+all[0]+all[2]+str+all[1];
l=press(qry);
if (l==last)
str.push_back(all[2]);
else if (l==last+1)
str.push_back(all[1]);
else str.push_back(all[0]);
last++;
}
qry=str+all[0]+str+all[1];
l=press(qry);
if (l==last+1){
qry=str+all[0];
l=press(qry);
if (l==last+1)
str.push_back(all[0]);
else str.push_back(all[1]);
}
else str.push_back(all[2]);
return str;
}
//g++ -std=gnu++14 -Wall -O2 -static -o combo grader.cpp combo.cpp
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |