#include "bits/stdc++.h"
using namespace std;
int query(string str);
#define sz(a) (int)a.size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string guess(int n, int s) {
vector<pair<int, char>> v;
for(int f = 0; f < s; ++f) {
char c = char('a' + f);
string paiu = string(n, c);
int x = query(paiu);
if(x > 0) {
v.push_back({x, c});
}
}
assert(v.size() > 0);
sort(v.rbegin(), v.rend());
string ans = string(v[0].first, v[0].second);
v.erase(v.begin());
assert(sz(ans) > 0);
if(!sz(v)) return ans;
for(auto noo: v) {
char c = noo.second;
int cnt = noo.first;
vector<int> add(sz(ans) + 5, 0);
string ff = ans;
string bruh = "";
for(int i = 0; i <= sz(ff); ++i) {
int lol = 0;
for(int j = 0; j < cnt; ++j) {
bruh += c;
string paiu = bruh;
for(int k = i; k < sz(ff); ++k) paiu += ff[k];
if(query(paiu) == sz(paiu)) {
++lol;
} else {
bruh.pop_back();
break;
}
}
cnt -= lol;
if(i < sz(ff)) bruh += ff[i];
}
ans = bruh;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
236 KB |
Guessed the password with 87 queries. |
2 |
Runtime error |
2 ms |
300 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 52 queries. |
2 |
Correct |
2 ms |
256 KB |
Guessed the password with 128 queries. |
3 |
Correct |
3 ms |
244 KB |
Guessed the password with 181 queries. |
4 |
Correct |
3 ms |
208 KB |
Guessed the password with 264 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
113 ms |
348 KB |
Guessed the password with 8257 queries. |
2 |
Correct |
103 ms |
348 KB |
Guessed the password with 10639 queries. |
3 |
Correct |
307 ms |
428 KB |
Guessed the password with 19403 queries. |
4 |
Correct |
426 ms |
364 KB |
Guessed the password with 26461 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
236 KB |
Guessed the password with 87 queries. |
2 |
Runtime error |
2 ms |
300 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
236 KB |
Guessed the password with 87 queries. |
2 |
Runtime error |
2 ms |
300 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |