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) {
// std::string p = "";
// for (int i = 0; i < 4 * N; ++i) {
// p += 'A';
// }
// int coins = press(p);
// std::string S = "";
// for (int i = 0; i < N; ++i) {
// S += 'A';
// }
// return S;
int n = N;
vector <char> a = {'A', 'B', 'X', 'Y'};
string ans = "";
char first = 'A';
string p = "AB";
int c = press(p);
if (c > 0){
p = "A";
c = press(p);
if (c > 0) first = 'A';
else first = 'B';
} else {
p = "X";
c = press(p);
if (c > 0) first = 'X';
else first = 'Y';
}
vector <char> b;
for (auto x : a) if (x != first) b.push_back(x);
ans += first;
if (n == 1) return ans;
for (int i = 1; i < n - 1; i++){
string go = "";
for (int j = 0; j < 4; j++){
go += ans;
if (j == 0) go += b[0];
else {
go += b[1];
go += b[j - 1];
}
}
c = press(go);
if (c == i) ans += b[2];
else if (c == i + 1) ans += b[0];
else ans += b[1];
}
p = ans + 'A' + ans + 'B';
c = press(p);
if (c == n) {
p = ans + 'A';
c = press(p);
if (c == n) ans += 'A';
else ans += 'B';
} else {
p = ans + 'X';
c = press(p);
if (c == n) ans += 'X';
else ans += 'Y';
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |