// Problem URL: https://oj.uz/problem/view/IOI18_combo
// Start Time: 5/22/2025, 1:37:39 PM
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define debug(x) std::cout << #x << ": " << x << "\n"
#define all(v) v.begin(), v.end()
#define li(i,a,b) for (int i = a; i < b; i++)
#define endl '\n'
#define mem(name,val) memset(name,val,sizeof(name))
#define min(a,b) (a<=b ? a : b)
#define max(a,b) (a>=b ? a : b)
string guess_sequence(int n)
{
vector<char> abc = {'A','B','X','Y'};
int r = press("AB");
char first;
if (r) {
first = press("A") ? 'A' : 'B';
} else {
first = press("X") ? 'X' : 'Y';
}
string pref(1, first);
vector<char> rest;
for (char c : abc) if (c != first) rest.push_back(c);
const char p = rest[0];
const char q = rest[1];
const char r_ = rest[2];
for (int i = 1; i < n - 1; ++i) {
string qstr;
qstr.reserve((i + 1) * 4 + 3);
qstr += pref; qstr.push_back(p);
qstr += pref; qstr.push_back(q); qstr.push_back(q);
qstr += pref; qstr.push_back(q); qstr.push_back(p);
qstr += pref; qstr.push_back(q); qstr.push_back(r_);
int k = press(qstr);
int delta = k - (int)pref.size();
if (delta == 0) pref.push_back(r_);
else if (delta == 1) pref.push_back(p);
else pref.push_back(q);
// int k = press(qstr);
// if (k == pref.size() + 1) pref.push_back(p);
// else if (k == pref.size() + 2) pref.push_back(r_);
// else pref.push_back(q);
}
if (n == 1) return pref;
string try1 = pref + q + pref + p;
int k = press(try1);
if (k == n - 1) {
pref.push_back(r_);
} else {
pref.push_back(press(pref + q) == n ? q : p);
}
return pref;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |