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;
string guess_sequence(int N) {
string prefix;
vector<string> l;
if(N == 1) {
if(press("A")) return "A";
if(press("B")) return "B";
if(press("X")) return "X";
return "Y";
}
if(press("AB")) {
if(press("B")) prefix = "B", l = {"A","X","Y"};
else prefix = "A", l = {"B","X","Y"};
}
else {
if(press("X")) prefix = "X", l = {"A","B","Y"};
else prefix = "Y", l = {"A","B","X"};
}
for(int i = 2; i < N; i++) {
string query = prefix + l[0];
query += prefix + l[1] + l[0];
query += prefix + l[1] + l[1];
query += prefix + l[1] + l[2];
int ans = press(query);
if(ans == i) prefix += l[0];
else if(ans == i+1) prefix += l[1];
else prefix += l[2];
}
if(press(prefix + l[0]) == N) {
//cout << prefix + l[0];
return prefix + l[0];
}
if(press(prefix + l[1]) == N) {
//cout << prefix + l[1];
return prefix + l[1];
}
//cout << prefix + l[2];
return prefix + l[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |