#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
template <typename T>
using v = vector<T>;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, k, n) for (int i=k; i < n; i++)
string guess_sequence(int N) {
int n = N;
string ans = "";
int c = press("AB");
if (c == 2) {
ans += "A";
}
else if (c == 1) {
c = press("A");
if (c) ans += "A";
else ans += "B";
}
else {
c = press("X");
if (c) {
ans += 'X';
}
else {
ans += "Y";
}
}
set<char> s;
s.insert('A'); s.insert('B'); s.insert('X'); s.insert('Y');
s.erase(ans[0]);
auto it = s.begin();
if (n == 1) return ans;
rep(i, 1, n-1) {
string q = "";
int cnt = 0;
for (auto x : s) {
string aux2 = ans + *it + x;
q += aux2;
}
auto itaux = next(it);
auto last = next(itaux);
q += (ans + *itaux);
c = press(q);
if (c == i+2) {
ans += *it;
}
else if (c == i+1) {
ans += *itaux;
}
else {
ans += *last;
}
}
auto itnext = next(it);
string query = ans + *it;
query += ans + *itnext;
c = press(query);
if (c == n) {
query = ans+*it;
c = press(query);
if (c == n) {
ans += *it;
}
else {
ans += *itnext;
}
}
else {
itnext = next(itnext);
ans += *itnext;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |