#include <bits/stdc++.h>
//#include "grader.h"
using namespace std;
int query(string str);
string divide(int n,int l,int r)
{
if(l==r)
{
//return string(guess(string(n,char('a'+l))) , char('a'+l));
return string(query(string(n,char('a'+l))) , char('a'+l));
}
int m=(l+r)/2;
string a=divide(n,l,m);
string b=divide(n,m+1,r);
string rez;
while(a.size() && b.size())
{
if(query(rez+a[0]+b)==rez.size()+1+b.size())
{
rez.push_back(a[0]);
a.erase(a.begin());
}
else
{
rez.push_back(b[0]);
b.erase(b.begin());
}
}
rez+=a;
rez+=b;
return rez;
}
string guess(int n, int s)
{
return divide(n,0,s-1);
}
Compilation message
password.cpp: In function 'std::string divide(int, int, int)':
password.cpp:19:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | if(query(rez+a[0]+b)==rez.size()+1+b.size())
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Guessed the password with 61 queries. |
2 |
Correct |
1 ms |
344 KB |
Guessed the password with 101 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Guessed the password with 49 queries. |
2 |
Correct |
1 ms |
344 KB |
Guessed the password with 117 queries. |
3 |
Correct |
1 ms |
344 KB |
Guessed the password with 92 queries. |
4 |
Correct |
2 ms |
344 KB |
Guessed the password with 197 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
448 KB |
Guessed the password with 3456 queries. |
2 |
Correct |
30 ms |
608 KB |
Guessed the password with 5025 queries. |
3 |
Correct |
33 ms |
960 KB |
Guessed the password with 6352 queries. |
4 |
Correct |
52 ms |
480 KB |
Guessed the password with 8693 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Guessed the password with 61 queries. |
2 |
Correct |
1 ms |
344 KB |
Guessed the password with 101 queries. |
3 |
Correct |
0 ms |
344 KB |
Guessed the password with 49 queries. |
4 |
Correct |
1 ms |
344 KB |
Guessed the password with 117 queries. |
5 |
Correct |
1 ms |
344 KB |
Guessed the password with 92 queries. |
6 |
Correct |
2 ms |
344 KB |
Guessed the password with 197 queries. |
7 |
Correct |
17 ms |
448 KB |
Guessed the password with 3456 queries. |
8 |
Correct |
30 ms |
608 KB |
Guessed the password with 5025 queries. |
9 |
Correct |
33 ms |
960 KB |
Guessed the password with 6352 queries. |
10 |
Correct |
52 ms |
480 KB |
Guessed the password with 8693 queries. |
11 |
Correct |
105 ms |
464 KB |
Guessed the password with 13638 queries. |
12 |
Correct |
92 ms |
944 KB |
Guessed the password with 12459 queries. |
13 |
Correct |
108 ms |
600 KB |
Guessed the password with 14392 queries. |
14 |
Correct |
86 ms |
860 KB |
Guessed the password with 13937 queries. |
15 |
Correct |
90 ms |
720 KB |
Guessed the password with 15073 queries. |
16 |
Correct |
82 ms |
468 KB |
Guessed the password with 14154 queries. |
17 |
Correct |
102 ms |
472 KB |
Guessed the password with 16054 queries. |
18 |
Correct |
114 ms |
724 KB |
Guessed the password with 15189 queries. |
19 |
Correct |
125 ms |
472 KB |
Guessed the password with 16410 queries. |
20 |
Correct |
107 ms |
592 KB |
Guessed the password with 14247 queries. |
21 |
Correct |
131 ms |
724 KB |
Guessed the password with 16849 queries. |
22 |
Correct |
120 ms |
700 KB |
Guessed the password with 15315 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Guessed the password with 61 queries. |
2 |
Correct |
1 ms |
344 KB |
Guessed the password with 101 queries. |
3 |
Correct |
0 ms |
344 KB |
Guessed the password with 49 queries. |
4 |
Correct |
1 ms |
344 KB |
Guessed the password with 117 queries. |
5 |
Correct |
1 ms |
344 KB |
Guessed the password with 92 queries. |
6 |
Correct |
2 ms |
344 KB |
Guessed the password with 197 queries. |
7 |
Correct |
17 ms |
448 KB |
Guessed the password with 3456 queries. |
8 |
Correct |
30 ms |
608 KB |
Guessed the password with 5025 queries. |
9 |
Correct |
33 ms |
960 KB |
Guessed the password with 6352 queries. |
10 |
Correct |
52 ms |
480 KB |
Guessed the password with 8693 queries. |
11 |
Correct |
105 ms |
464 KB |
Guessed the password with 13638 queries. |
12 |
Correct |
92 ms |
944 KB |
Guessed the password with 12459 queries. |
13 |
Correct |
108 ms |
600 KB |
Guessed the password with 14392 queries. |
14 |
Correct |
86 ms |
860 KB |
Guessed the password with 13937 queries. |
15 |
Correct |
90 ms |
720 KB |
Guessed the password with 15073 queries. |
16 |
Correct |
82 ms |
468 KB |
Guessed the password with 14154 queries. |
17 |
Correct |
102 ms |
472 KB |
Guessed the password with 16054 queries. |
18 |
Correct |
114 ms |
724 KB |
Guessed the password with 15189 queries. |
19 |
Correct |
125 ms |
472 KB |
Guessed the password with 16410 queries. |
20 |
Correct |
107 ms |
592 KB |
Guessed the password with 14247 queries. |
21 |
Correct |
131 ms |
724 KB |
Guessed the password with 16849 queries. |
22 |
Correct |
120 ms |
700 KB |
Guessed the password with 15315 queries. |
23 |
Correct |
179 ms |
952 KB |
Guessed the password with 23612 queries. |
24 |
Correct |
172 ms |
1676 KB |
Guessed the password with 22226 queries. |
25 |
Correct |
178 ms |
808 KB |
Guessed the password with 23794 queries. |
26 |
Correct |
187 ms |
952 KB |
Guessed the password with 23332 queries. |
27 |
Correct |
176 ms |
748 KB |
Guessed the password with 23763 queries. |
28 |
Correct |
169 ms |
700 KB |
Guessed the password with 23045 queries. |
29 |
Correct |
190 ms |
892 KB |
Guessed the password with 23847 queries. |
30 |
Correct |
176 ms |
960 KB |
Guessed the password with 22506 queries. |