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 alpha;
string go(const string& pre, int N, int S) {
if (S < 0) return "";
swap(alpha[S], alpha[rand() % (S + 1)]);
string q = pre + string(N - sz(pre), alpha[S]);
int cnt = query(q) - seen[alpha[S] - 'a'] - sz(pre);
//cerr << "pre " << pre << " S " << alpha[S] << " cnt " << cnt << endl;
string npre = pre + string(cnt, alpha[S]);
vector<string> tres;
for (int i = cnt; i >= 0; --i) {
tres.push_back(go(npre, N, S - 1));
npre.pop_back();
}
seen[alpha[S] - 'a'] += cnt;
string res;
for (int i = sz(tres) - 1; i >= 0; --i) {
res.insert(res.end(), all(tres[i]));
if (i) res.push_back(alpha[S]);
}
return res;
}
string guess(int N, int S) {
srand(time(NULL));
rep(i,0,S) alpha.push_back('a' + i);
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... |