#include "combo.h"
#include <string>
#include <iostream>
using namespace std;
char ci[4] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int N) {
string ab = "AB";
string ret = "";
char x = 0, y = 0, z = 0;
if(press(ab) >= 1){
if(press("A") == 1) ret += 'A';
else ret += 'B';
}
else{
if(press("X") == 1) ret += 'X';
else ret += 'Y';
}
for(int i = 0; i < 4; i ++){
if(ci[i] == ret[0]) continue;
if(x == 0) x = ci[i];
else if(y == 0) y = ci[i];
else z = ci[i];
}
for(int i = 2; i <= N; i ++){
if(i == N - 1){
if(press(ret + x) == N) ret += x;
else if(press(ret + y) == N) ret += y;
else ret += z;
}
else{
string chk;
chk += (ret + x + x);
chk += (ret + x + y);
chk += (ret + x + z);
chk += (ret + y);
int pr = press(chk);
if(pr >= i + 1) ret += x;
else if(pr == i) ret += y;
else ret += z;
}
}
//cout << ret;
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |