This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define ui unsigned int
#define pii pair<int, int>
#define piii pair<int, pii>
#define pb push_back
#define f first
#define s second
#define oo (1ll << 60)
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int query(string str);
string guess(int n, int s) {
string str;
vector<pii>countLetter(s);
for(int i = 0; i < s; ++i) {
str = "";
for(int j = 0; j < n; ++j) {
str += ('a' + i);
}
countLetter[i].f = query(str);
countLetter[i].s = i;
}
sort(countLetter.begin(), countLetter.end());
str = "";
for(int i = 0; i < countLetter[0].f; ++i) {
str += ('a' + countLetter[0].s);
}
for(int i = 1; i < s; ++i) {
string add = "";
for(int j = 0; j < countLetter[i].f; ++j) {
add += ('a' + countLetter[i].s);
}
int len = str.length();
vector<int>comesAfter(len + 2);
comesAfter[0] = countLetter[i].f;
comesAfter[len + 1] = 0;
for(int j = 1; j <= len; ++j) {
string ask = str.substr(0, j) + add;
comesAfter[j] = query(ask) - j;
}
for(int j = 0; j <= len; ++j) {
for(int k = comesAfter[j]; k > comesAfter[j + 1]; --k) {
str.insert(str.begin() + j + countLetter[i].f - k, 'a' + countLetter[i].s);
}
}
}
return str;
}
# | 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... |