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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
string del(string s, char ch) {
string t;
for (auto &x : s) {
if (x != ch) {
t += x;
}
}
return t;
}
mt19937 rng((long long) (new char));
string mult(char ch, int x) {
string s;
for (int i = 1; i <= x; i++) {
s += ch;
}
return s;
}
string guess_sequence(int n) {
string sol;
string posi = "ABXY";
bool found = 0;
for (int j = 0; j < 3; j++) {
if (press(sol + posi[j]) == 1) {
found = 1;
sol += posi[j];
break;
}
}
if (found == 0) {
sol += posi[3];
}
posi = del(posi, sol[0]);
while ((int) sol.size() + 1 <= n) {
shuffle(posi.begin(), posi.end(), rng);
char a = posi[0];
char b = posi[1];
char c = posi[2];
int ret = press(sol + mult(a, n - (int) sol.size()) + sol + b);
if (ret == (int) sol.size()) {
sol += c;
continue;
}
if (ret > (int) sol.size() + 1) {
sol = sol + mult(a, ret - (int) sol.size());
continue;
}
if (ret == (int) sol.size() + 1) {
if ((int) sol.size() == n - 1) {
ret = press(sol + a);
if (ret == n) {
sol += a;
continue;
} else {
sol += b;
continue;
}
}
/// + ab
/// + ac
/// + b
}
bool found = 0;
for (int j = 0; j < 2; j++) {
if (press(sol + posi[j]) == (int) sol.size() + 1) {
found = 1;
sol += posi[j];
break;
}
}
if (found == 0) {
sol += posi[2];
}
}
return sol;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |