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"
using namespace std;
#define sz(a) (int)(a.size())
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
string guess_sequence(int N) {
string res = "";
char c[] = {'A', 'B', 'X', 'Y'}, f[3];
REP(i, 0, N) {
int ind = 0;
string q = res;
if(sz(res) > 0) {
REP(j, 0, 4) {
if(res[0] != c[j]) {
if(sz(q) > sz(res)) {
f[ind++] = c[j];
if(ind == 2) REP(k, 0, 4) if(c[k] != res[0]) q += res + c[j] + c[k];
}
else q += c[j], f[ind++] = c[j];
}
}
}
if(sz(q) > 4*N || i == 0) {
if(press(res + "A" + res + "B") >= i+1) res += ((press(res + "A") == i+1) ? 'A' : 'B');
else res += ((press(res + "X") == i+1) ? 'X' : 'Y');
} else {
int ret = press(q);
if(ret == i+1) res += f[0];
else if(ret == i+2) res += f[1];
else res += f[2];
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |