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;
const string code = "ABXYY";
// int press(string s) {
// int ans = 0;
// // cerr << "a";
// for (int i = 0; i < s.size();) {
// int j = i, ptr = 0;
// while (j < s.size() && code[ptr] == s[j]) {
// j++; ptr++;
// }
// i = max(j, i + 1);
// // cerr << s << " " << ptr << "\n";
// ans = max(ans, ptr);
// }
// return ans;
// }
string guess_sequence(int N) {
vector<char> el = {'A', 'B', 'X', 'Y'};
vector<char> fin;
string ans = "";
string c = "AB";
if (!press(c)) {
c = "XY";
}
if (!press(c.substr(1))) {
c = c[0];
} else {
c = c[1];
}
ans += c;
for (auto u : el) {
if (u != c[0]) {
fin.push_back(u);
}
}
for (int i = 2; i < N; ++i) {
string guess = ans + fin[0] + fin[0] + ans + fin[0] + fin[1] +
ans + fin[0] + fin[2] + ans + fin[1];
int num = press(guess);
if (num == i - 1) {
ans += fin[2];
} else if (num == i) {
ans += fin[1];
} else {
ans += fin[0];
}
}
if (N > 1) {
string guess = ans + fin[0];
if (press(guess) == N) {
ans += fin[0];
}
guess = ans + fin[1];
if (press(guess) == N) {
ans += fin[1];
} else {
ans += fin[2];
}
}
return ans;
}
// int main () {
// cout << guess_sequence(code.size());
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |