#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "C:\GCC\debug.h"
#else
#define debug(...) void(42)
#endif
int cnt = 0;
int query(string s);
string guess(int n, int s) {
string res = "";
vector<int> freq(s);
for (int i = 0; i < s; i++) {
string x = "";
for (int it = 0; it < n; it++) {
x += (i + 'a');
}
freq[i] = query(x);
}
int ptr = 0;
while (freq[ptr] == 0) {
++ptr;
}
for (int i = 0; i < freq[ptr]; i++) {
res += (ptr + 'a');
}
int best = query(res);
for (int i = ptr + 1; i < s; i++) {
if (freq[i] == 0) {
continue;
}
int cur = i + 'a';
auto Build = [&](int pos) {
int it = 0;
string tmp = "";
while (it < pos) {
tmp += res[it];
++it;
}
tmp += cur;
while (it < (int) res.length()) {
tmp += res[it];
it++;
}
return tmp;
};
int pts = 0;
for (int j = 0; j < (int) res.length(); j++) {
string tmp = Build(j);
int cB = query(tmp);
if (best < cB) {
pts++;
best = cB;
swap(res, tmp);
if (pts == freq[i]) {
break;
}
if (best == n) {
return res;
}
}
}
int rem = n - (int) res.length();
debug(res);
string nRes = res;
nRes.insert((int) nRes.length(), rem, cur);
best = query(nRes);
if (best == n) {
return nRes;
}
nRes.resize(best);
swap(nRes, res);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
42 ms |
324 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |