#include "bits/stdc++.h"
using namespace std;
int query(string str);
#define sz(a) (int)a.size()
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.begin(), v.end());
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 = "";
int lol = 0;
for(int i = 0; i <= sz(ff); ++i) {
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 76 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 187 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Returned early from guess() after 16 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
208 KB |
Returned early from guess() after 307 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 76 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 187 queries. |
3 |
Incorrect |
1 ms |
208 KB |
Returned early from guess() after 16 queries. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 76 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 187 queries. |
3 |
Incorrect |
1 ms |
208 KB |
Returned early from guess() after 16 queries. |
4 |
Halted |
0 ms |
0 KB |
- |