This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
};
for (int j = 0; j < (int) res.length(); j++) {
string tmp = Build(j);
int cB = query(tmp);
if (best < cB) {
best = cB;
swap(res, tmp);
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 |
---|
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... |