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;
char getfirst () {
string u = "AB";
int y = press(u);
if (y >= 1) {
u = "A";
y = press(u);
if (y == 1) return 'A';
return 'B';
} else {
u = "X";
y = press(u);
if (y == 1) return 'X';
return 'Y';
}
}
string guess_sequence (int n) {
char x = getfirst();
vector <char> dd = {'A', 'B', 'X', 'Y'};
for (int i = 0; i < 4; i++) {
if (dd[i] == x) {
dd.erase(dd.begin() + i);
}
}
string ret; ret += x;
if (n == 1) return ret;
for (int i = 2; i < n; i++) {
string f1 = ret; f1 += dd[0]; f1 += dd[0];
string f2 = ret; f2 += dd[0]; f2 += dd[1];
string f3 = ret; f3 += dd[0]; f3 += dd[2];
string f4 = ret; f4 += dd[1];
string g = f1 + f2 + f3 + f4;
int y = press(g);
if (y == i - 1) {
ret += dd[2];
} else if (y == i) {
ret += dd[1];
} else {
ret += dd[0];
}
}
for (int i = 0; i < 2; i++) {
string u = ret; u += dd[i];
int g = press(u);
if (g == n) {
ret = u;
break;
}
if (i == 1) ret += dd[2];
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |