#include "bits/stdc++.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
int query(string s);
string guess(int _N, int _C) {
priority_queue<pair<int, string>> pq;
int n = _N, c = _C;
for (int i = 0; i < c; ++i) {
string cur;
for (int j = 0; j < n; ++j) {
cur += char('a' + i);
}
int x = query(cur);
if (x > 0) {
cur.clear();
for (int j = 0; j < x; ++j) {
cur += char('a' + i);
}
pq.push(make_pair(x, cur));
}
}
while ((int)pq.size() > 1) {
string x = pq.top().second;
pq.pop();
string y = pq.top().second;
pq.pop();
string res;
int px = 0, py = 0;
while (px < (int)x.size() and py < (int)y.size()) {
string g = res + x[px];
for (int i = py; i < (int)y.size(); ++i) {
g += y[i];
}
int cur_g = query(g);
if (cur_g > (int)res.size() + (int)y.size() - py) {
res += x[px++];
} else {
res += y[py++];
}
}
while (px < (int)x.size()) {
res += x[px++];
}
while (py < (int)y.size()) {
res += y[py++];
}
pq.push(make_pair((int)res.size(), res));
}
return pq.top().second;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |