#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int query(string q);
string guess(int N, int S) {
string res;
{
string q(N, 'a');
res = string(query(q), 'a');
}
for (int i = 1; i < S; ++i) {
int included = 0;
int at = sz(res);
while (true) {
int lo = -1;
int hi = at + 1;
while (hi - lo > 1) {
int mid = (lo + hi + 1) / 2;
string q = res.substr(0, mid) + string(included + 1, 'a' + i);
if (query(q) == sz(q)) {
lo = mid;
} else {
hi = mid;
}
}
if (lo == -1) break;
res.insert(res.begin() + lo, 'a' + i);
at = hi;
++included;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 87 queries. |
2 |
Correct |
3 ms |
200 KB |
Guessed the password with 154 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 83 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 115 queries. |
3 |
Correct |
6 ms |
200 KB |
Guessed the password with 326 queries. |
4 |
Correct |
5 ms |
200 KB |
Guessed the password with 374 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
416 KB |
Guessed the password with 6459 queries. |
2 |
Correct |
104 ms |
292 KB |
Guessed the password with 8544 queries. |
3 |
Correct |
138 ms |
320 KB |
Guessed the password with 11601 queries. |
4 |
Correct |
208 ms |
320 KB |
Guessed the password with 16209 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 87 queries. |
2 |
Correct |
3 ms |
200 KB |
Guessed the password with 154 queries. |
3 |
Correct |
1 ms |
200 KB |
Guessed the password with 83 queries. |
4 |
Correct |
2 ms |
200 KB |
Guessed the password with 115 queries. |
5 |
Correct |
6 ms |
200 KB |
Guessed the password with 326 queries. |
6 |
Correct |
5 ms |
200 KB |
Guessed the password with 374 queries. |
7 |
Correct |
35 ms |
416 KB |
Guessed the password with 6459 queries. |
8 |
Correct |
104 ms |
292 KB |
Guessed the password with 8544 queries. |
9 |
Correct |
138 ms |
320 KB |
Guessed the password with 11601 queries. |
10 |
Correct |
208 ms |
320 KB |
Guessed the password with 16209 queries. |
11 |
Correct |
234 ms |
552 KB |
Guessed the password with 19707 queries. |
12 |
Correct |
326 ms |
276 KB |
Guessed the password with 23238 queries. |
13 |
Correct |
304 ms |
456 KB |
Guessed the password with 23804 queries. |
14 |
Correct |
270 ms |
336 KB |
Guessed the password with 25505 queries. |
15 |
Correct |
277 ms |
576 KB |
Guessed the password with 24474 queries. |
16 |
Correct |
252 ms |
364 KB |
Guessed the password with 27164 queries. |
17 |
Correct |
155 ms |
456 KB |
Guessed the password with 23424 queries. |
18 |
Correct |
242 ms |
588 KB |
Guessed the password with 28350 queries. |
19 |
Correct |
263 ms |
456 KB |
Guessed the password with 24022 queries. |
20 |
Correct |
375 ms |
452 KB |
Guessed the password with 29370 queries. |
21 |
Correct |
360 ms |
320 KB |
Guessed the password with 25610 queries. |
22 |
Correct |
266 ms |
344 KB |
Guessed the password with 27452 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 87 queries. |
2 |
Correct |
3 ms |
200 KB |
Guessed the password with 154 queries. |
3 |
Correct |
1 ms |
200 KB |
Guessed the password with 83 queries. |
4 |
Correct |
2 ms |
200 KB |
Guessed the password with 115 queries. |
5 |
Correct |
6 ms |
200 KB |
Guessed the password with 326 queries. |
6 |
Correct |
5 ms |
200 KB |
Guessed the password with 374 queries. |
7 |
Correct |
35 ms |
416 KB |
Guessed the password with 6459 queries. |
8 |
Correct |
104 ms |
292 KB |
Guessed the password with 8544 queries. |
9 |
Correct |
138 ms |
320 KB |
Guessed the password with 11601 queries. |
10 |
Correct |
208 ms |
320 KB |
Guessed the password with 16209 queries. |
11 |
Correct |
234 ms |
552 KB |
Guessed the password with 19707 queries. |
12 |
Correct |
326 ms |
276 KB |
Guessed the password with 23238 queries. |
13 |
Correct |
304 ms |
456 KB |
Guessed the password with 23804 queries. |
14 |
Correct |
270 ms |
336 KB |
Guessed the password with 25505 queries. |
15 |
Correct |
277 ms |
576 KB |
Guessed the password with 24474 queries. |
16 |
Correct |
252 ms |
364 KB |
Guessed the password with 27164 queries. |
17 |
Correct |
155 ms |
456 KB |
Guessed the password with 23424 queries. |
18 |
Correct |
242 ms |
588 KB |
Guessed the password with 28350 queries. |
19 |
Correct |
263 ms |
456 KB |
Guessed the password with 24022 queries. |
20 |
Correct |
375 ms |
452 KB |
Guessed the password with 29370 queries. |
21 |
Correct |
360 ms |
320 KB |
Guessed the password with 25610 queries. |
22 |
Correct |
266 ms |
344 KB |
Guessed the password with 27452 queries. |
23 |
Correct |
418 ms |
432 KB |
Guessed the password with 45544 queries. |
24 |
Correct |
436 ms |
556 KB |
Guessed the password with 43264 queries. |
25 |
Correct |
544 ms |
700 KB |
Guessed the password with 45919 queries. |
26 |
Correct |
526 ms |
636 KB |
Guessed the password with 44348 queries. |
27 |
Correct |
478 ms |
408 KB |
Guessed the password with 45771 queries. |
28 |
Correct |
502 ms |
560 KB |
Guessed the password with 44856 queries. |
29 |
Correct |
359 ms |
640 KB |
Guessed the password with 46088 queries. |
30 |
Correct |
448 ms |
420 KB |
Guessed the password with 44593 queries. |