#include <string>
#include <queue>
using namespace std;
int query(string q);
string guess(int n, int c) {
priority_queue<pair<int, string>> pq;
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;
while (!x.empty()) {
string g = res + x[0] + y;
if (query(g) == (int)g.size()) {
res += x[0];
x.erase(x.begin());
} else {
res += y[0];
y.erase(y.begin());
}
}
if (!y.empty()) {
res += y;
}
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... |