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;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int query(string q);
vector<int> seen(26);
string go(const string& pre, int N, int S) {
if (S < 0) return "";
string q = pre + string(N - sz(pre), 'a' + S);
int cnt = query(q) - seen[S] - sz(pre);
cerr << "pre " << pre << " S " << S << " cnt " << cnt << endl;
string res;
for (int i = cnt; i >= 0; --i) {
string npre = pre;
rep(j,0,i) npre.push_back('a' + S);
if (i != cnt) {
res.insert(res.begin(), 'a' + S);
seen[S]++;
}
res = go(npre, N, S - 1) + res;
}
return res;
}
string guess(int N, int S) {
return go("", N, S - 1);
}
# | 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... |