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;
std::string guess_sequence(int N) {
string s = "";
string p = "AB";
int coins = press(p);
if (coins == 2) s = p;
else if (coins == 1) {
p = "A";
coins = press(p);
if (coins == 1) s = "A";
else s = "B";
} else {
p = "X";
coins = press(p);
if (coins == 1) s = "X";
else s = "Y";
}
string A = "ABXY";
string a = "";
for (char c : A) {
if (s[0] != c) a = a + c;
}
coins = 1;
int sz = s.size();
while (sz < N - 1) {
p = "";
for (int i = 0; i < 4; i++) {
p = p + s;
if (i < 3) {
p = p + a[0];
p = p + a[i];
} else p = p + a[1];
}
int k = press(p) - s.size();
if (k == 2) {
s += a[0];
} else if (k == 1) {
s += a[1];
} else {
s += a[2];
}
sz = s.size();
}
if (sz == N) {
return s;
}
p = s;
p += a[0];
p += s;
p += a[1];
int k = press(p) - s.size();
if (k == 1) {
p = s;
p += a[0];
if (press(p) - s.size() == 1) {
s += a[0];
} else s += a[1];
} else s += a[2];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |