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 <algorithm>
#include <string>
using namespace std;
char s[5] = "ABXY";
string p, res;
void Put(int pv) {
p += s[pv];
}
void Clear() {
p = "";
}
std::string guess_sequence(int N) {
int i, st = -1, j;
Clear();
for (int i = 0; i < 2 * N; i++) Put(0);
for (int i = 0; i < 2 * N; i++) Put(1);
int t = press(p);
if (t) {
Clear();
for (i = 0; i < 4 * N; i++)Put(0);
t = press(p);
if (t)st = 0;
else st = 1;
}
else {
Clear();
for (i = 0; i < 4 * N; i++)Put(2);
t = press(p);
if (t)st = 2;
else st = 3;
}
res = "";
res += s[st];
if (N == 1)return res;
int p1 = (st + 1) % 4;
int p2 = (st + 2) % 4;
int p3 = (st + 3) % 4;
for (i = 2; i < N; i++) {
Clear();
p += res;
Put(p1);
for (j = 0; j < N - i; j++)Put(p1);
p += res;
Put(p1);
for (j = 0; j < N - i; j++)Put(p2);
p += res;
Put(p1);
for (j = 0; j < N - i; j++)Put(p3);
p += res;
Put(p2);
for (j = 0; j < N - i; j++)Put(st);
t = press(p);
if (t == i - 1)res += s[p3];
else if (t == i)res += s[p2];
else res += s[p1];
}
Clear();
p += res;
Put(p1);
for (i = 0; i < 3 * N; i++)Put(st);
t = press(p);
if (t == N)res += s[p1];
else {
Clear();
p += res;
Put(p2);
for (i = 0; i < 3 * N; i++)Put(st);
t = press(p);
if (t == N)res += s[p2];
else res += s[p3];
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |