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 str);
string guess(int n, int s) {
string endChars = "";
vector<int> freq(s);
for (int i = 0; i < s; i++) {
string x = "";
for (int it = 0; it < n; it++) {
x.push_back(i + 'a');
}
freq[i] = query(x);
}
for (int pos = n - 1; pos >= 0; pos--) {
for (int i = 0; i < s; i++) {
if (freq[i] > 0) {
string build = "";
for (int it = 0; it < freq[i]; it++) {
build.push_back(i + 'a');
}
bool work = true;
if ((int) build.size() + 1 + (int) endChars.size() <= n) {
for (int j = 0; j < s; j++) {
string tmp = "";
for (auto c : build) {
tmp.push_back(c);
}
tmp.push_back(j + 'a');
for (auto c : endChars) {
tmp.push_back(c);
}
assert((int) tmp.size() >= 1 && (int) tmp.size() <= n);
if (query(tmp) == (int) tmp.length()) {
work = false;
break;
}
}
}
if (work) {
freq[i] -= 1;
string x = "";
x.push_back(i + 'a');
endChars = x + endChars;
break;
}
}
}
}
return endChars;
}
# | 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... |