#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) {
auto Build = [&](vector<char> x) {
assert((int) x.size() >= 1 && (int) x.size() <= n);
for (auto c : x) {
assert(c >= 'a' && c < 'a' + s);
}
string ret = "";
for (int i = 0; i < (int) x.size(); i++) {
ret += x[i];
}
return ret;
};
deque<char> res;
vector<int> freq(s);
for (int i = 0; i < s; i++) {
vector<char> x;
for (int it = 0; it < n; it++) {
x.push_back(char(i + 'a'));
}
freq[i] = query(Build(x));
}
for (int pos = n - 1; pos >= 0; pos--) {
for (int i = 0; i < s; i++) {
if (freq[i] > 0) {
vector<char> build;
for (int it = 0; it < freq[i]; it++) {
build.push_back(char(i + 'a'));
}
bool work = true;
if ((int) build.size() + 1 + (int) res.size() <= n) {
for (int j = 0; j < s; j++) {
vector<char> tmp;
for (auto c : build) {
tmp.push_back(c);
}
tmp.push_back(char(j + 'a'));
for (auto c : res) {
tmp.push_back(c);
}
assert((int) tmp.size() >= 1 && (int) tmp.size() <= n);
if (query(Build(tmp)) == (int) tmp.size()) {
work = false;
break;
}
}
}
if (work) {
freq[i] -= 1;
res.push_front(char(i + 'a'));
break;
}
}
}
}
string ret = "";
for (int i = 0; i < (int) res.size(); i++) {
ret += res[i];
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
208 KB |
Guessed the password with 427 queries. |
2 |
Correct |
6 ms |
208 KB |
Guessed the password with 1209 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Guessed the password with 135 queries. |
2 |
Runtime error |
4 ms |
208 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
483 ms |
428 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
208 KB |
Guessed the password with 427 queries. |
2 |
Correct |
6 ms |
208 KB |
Guessed the password with 1209 queries. |
3 |
Correct |
2 ms |
208 KB |
Guessed the password with 135 queries. |
4 |
Runtime error |
4 ms |
208 KB |
Execution killed with signal 13 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
208 KB |
Guessed the password with 427 queries. |
2 |
Correct |
6 ms |
208 KB |
Guessed the password with 1209 queries. |
3 |
Correct |
2 ms |
208 KB |
Guessed the password with 135 queries. |
4 |
Runtime error |
4 ms |
208 KB |
Execution killed with signal 13 |
5 |
Halted |
0 ms |
0 KB |
- |