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;
#define pb push_back
string guess_sequence(int N) {
char st;
int p = press("AB");
if (p) {
p = press("A");
if (p) st = 'A';
else st = 'B';
} else {
p = press("X");
if (p) st = 'X';
else st = 'Y';
}
vector<char> valid;
for (char c : {'A', 'B', 'X', 'Y'}) {
if (c != st) valid.pb(c);
}
string s = "";
s.pb(st);
if (N == 1) return s;
for (int i = 1; i + 1 < N; i++) {
string q = s;
q.pb(valid[0]);
q += s;
q.pb(valid[1]);
q.pb(valid[0]);
q += s;
q.pb(valid[1]);
q.pb(valid[1]);
q += s;
q.pb(valid[1]);
q.pb(valid[2]);
int p = press(q);
if (p == (int)s.size()) s.pb(valid[2]);
else if (p == (int)s.size() + 1) s.pb(valid[0]);
else s.pb(valid[1]);
}
p = press(s + valid[0] + s + valid[1]);
if (p == (int)s.size() + 1) {
p = press(s + valid[0]);
if (p == (int)s.size() + 1) s += valid[0];
else s += valid[1];
} else {
s += valid[2];
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |