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 <string>
#include <iostream>
#include <vector>
using namespace std;
int vpress(string a){
// cout << "try - " << a;
int val = press(a);
// cout << " - " << val << endl;
return val;
}
string repeat(int a,string str){
for(int i=0;i<a-1;i++){
str += str;
}
return str;
}
string guess_sequence(int N) {
string ans = "";
vector<char> possible = {'A','B','X','Y'};;
if(vpress("AB") >= 1){
if(vpress("A") == 1){
ans = "A";
possible.erase(possible.begin()+0);
}else{
ans = "B";
possible.erase(possible.begin()+1);
}
}else{
if(vpress("X") == 1){
ans = "X";
possible.erase(possible.begin()+2);
}else{
ans = "Y";
possible.erase(possible.begin()+3);
}
}
if(N == 1)
return ans;
int counter = 1;
for(int i =1;i<N-1;i++){
string temp = ans+string(1,possible[0]);
temp += ans+string(1,possible[1])+string(1,possible[0]);
temp += ans+string(1,possible[1])+string(1,possible[1]);
temp += ans+string(1,possible[1])+string(1,possible[2]);
// temp += repeat(2,(ans+string(1,possible[1])));
int val = vpress(temp);
if(val == counter+1){
ans = ans + string(1,possible[0]);
}else if(val == counter+2){
ans = ans + string(1,possible[1]);
}else {
ans = ans + string(1,possible[2]);
}
counter += 1;
// cout << "ans -> " << ans << " " << counter << " " << N << endl;
}
if(vpress(ans+string(1,possible[0])) == N){
ans = ans + string(1,possible[0]);
}else{
if(vpress(ans+string(1,possible[1])) == N){
ans = ans + string(1,possible[1]);
}else{
ans = ans + string(1,possible[2]);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |