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 guess_sequence(int N) {
string s = "", p = "", lets = "ABXY";
p += lets[0];
p += lets[1];
// cerr << "p: " << p << '\n';
if (press(p)) {
p = lets[0];
// cerr << "p: " << p << '\n';
if (press(p)) {
s += lets[0];
} else {
s += lets[1];
}
} else {
p = lets[2];
// cerr << "p: " << p << '\n';
if (press(p)) {
s += lets[2];
} else {
s += lets[3];
}
}
// cerr << "first: " << s << '\n';
for (int i = 0; i < 4; ++i) {
if (lets[i] == s[0]) {
swap(lets[i], lets.back());
lets.pop_back();
break;
}
}
for (int i = 0; i < N - 2; ++i) {
p = s + lets[0];
p += s + lets[1] + lets[0];
p += s + lets[1] + lets[1];
p += s + lets[1] + lets[2];
// cerr << "i: " << i << ", p: " << p << '\n';
int len = press(p);
// cerr << "len: " << len << '\n';
if (len == (int)s.size() + 1) {
s += lets[0];
} else if (len == (int)s.size() + 2) {
s += lets[1];
} else {
s += lets[2];
}
}
// cerr << "last: " << s << '\n';
// cerr << "p: " << s + lets[0] + s + lets[1] << '\n';
if (press(s + lets[0] + s + lets[1]) == N) {
if (press(s + lets[0]) == N) {
s += lets[0];
} else {
s += lets[1];
}
} else {
s += lets[2];
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |