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 <string>
#include "combo.h"
#include <vector>
#include <deque>
using namespace std;
const int maxN = 2e3 + 10;
int ans[maxN];
string c;
vector<int> tmp;
string getStr(){
string s = "";
for(int x : tmp) s += c[x];
return s;
}
std::string guess_sequence(int N) {
int r;
c = "";
string current = "AB";
r = press(current);
if(r){
current = "A";
r = press(current);
if(r) c = "ABXY";
else c = "BAXY";
} else {
current = "Y";
r = press(current);
if(r) c = "YABX";
else c = "XABY";
}
for(int i = 1; i < N - 1; i++){
tmp.clear();
for(int j = 0; j < i; j++) tmp.push_back(ans[j]);
tmp.push_back(1);
for(int j = 0; j < i; j++) tmp.push_back(ans[j]);
tmp.push_back(2);
tmp.push_back(1);
for(int j = 0; j < i; j++) tmp.push_back(ans[j]);
tmp.push_back(2);
tmp.push_back(2);
for(int j = 0; j < i; j++) tmp.push_back(ans[j]);
tmp.push_back(2);
tmp.push_back(3);
r = press(getStr());
if(r == i) ans[i] = 3;
else if(r == i + 1) ans[i] = 1;
else ans[i] = 2;
}
if(N == 1){
tmp.push_back(0);
return getStr();
}
tmp.clear();
for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]);
tmp.push_back(1);
for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]);
tmp.push_back(2);
if(press(getStr()) == N){
tmp.clear();
for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]);
tmp.push_back(1);
if(press(getStr()) == N) return getStr();
tmp[N - 1] = 2;
return getStr();
}
tmp.clear();
for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]);
tmp.push_back(3);
return getStr();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |