#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
string substr(string s, int l, int r) {
string ans;
for (int i = l; i <= r; i++)
ans += s[i];
return ans;
}
int query(string);
vi cnt;
string merge(string s,string t){
if(s.size()<t.size())
swap(s,t);
for(int i=-1; i<int(s.size()); i++){
if(!t.size())break;
string cur=s.substr(0,i+1)+string(1,t[0])+s.substr(i+1,s.size()-(i+1));
if(query(cur)==cur.size()){
s=s.substr(0,i+1)+string(1,t[0])+s.substr(i+1,s.size()-(i+1));
t=t.substr(1,t.size()-1);
}
}
return s;
}
string dfs(int l,int r,int n){
if(l>r)return "";
else if(l==r)return string(cnt[l],l+'a');
int m=(l+r)/2;
return merge(dfs(l,m,n),dfs(m+1,r,n));
}
string guess(int n,int AB){
cnt=vi(26);
int sum=0;
for(int i=0; i<AB; i++){
int ans=query(string(n,i+'a'));
cnt[i]=ans;
sum+=ans;
}
return dfs(0,AB-1,n);
}
Compilation message
password.cpp: In function 'std::string merge(std::string, std::string)':
password.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | if(query(cur)==cur.size()){
| ~~~~~~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 68 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 111 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Guessed the password with 52 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 116 queries. |
3 |
Correct |
1 ms |
292 KB |
Guessed the password with 105 queries. |
4 |
Correct |
3 ms |
200 KB |
Guessed the password with 199 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
464 KB |
Guessed the password with 3462 queries. |
2 |
Correct |
30 ms |
376 KB |
Guessed the password with 5035 queries. |
3 |
Correct |
63 ms |
504 KB |
Guessed the password with 6355 queries. |
4 |
Correct |
93 ms |
392 KB |
Guessed the password with 8715 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 68 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 111 queries. |
3 |
Correct |
1 ms |
204 KB |
Guessed the password with 52 queries. |
4 |
Correct |
2 ms |
200 KB |
Guessed the password with 116 queries. |
5 |
Correct |
1 ms |
292 KB |
Guessed the password with 105 queries. |
6 |
Correct |
3 ms |
200 KB |
Guessed the password with 199 queries. |
7 |
Correct |
27 ms |
464 KB |
Guessed the password with 3462 queries. |
8 |
Correct |
30 ms |
376 KB |
Guessed the password with 5035 queries. |
9 |
Correct |
63 ms |
504 KB |
Guessed the password with 6355 queries. |
10 |
Correct |
93 ms |
392 KB |
Guessed the password with 8715 queries. |
11 |
Correct |
156 ms |
388 KB |
Guessed the password with 13650 queries. |
12 |
Correct |
106 ms |
392 KB |
Guessed the password with 12460 queries. |
13 |
Correct |
146 ms |
392 KB |
Guessed the password with 14407 queries. |
14 |
Correct |
108 ms |
508 KB |
Guessed the password with 13973 queries. |
15 |
Correct |
184 ms |
396 KB |
Guessed the password with 15077 queries. |
16 |
Correct |
148 ms |
536 KB |
Guessed the password with 14160 queries. |
17 |
Correct |
181 ms |
520 KB |
Guessed the password with 16061 queries. |
18 |
Correct |
178 ms |
400 KB |
Guessed the password with 15212 queries. |
19 |
Correct |
153 ms |
396 KB |
Guessed the password with 16417 queries. |
20 |
Correct |
163 ms |
516 KB |
Guessed the password with 14253 queries. |
21 |
Correct |
171 ms |
400 KB |
Guessed the password with 16875 queries. |
22 |
Correct |
125 ms |
524 KB |
Guessed the password with 15478 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 68 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 111 queries. |
3 |
Correct |
1 ms |
204 KB |
Guessed the password with 52 queries. |
4 |
Correct |
2 ms |
200 KB |
Guessed the password with 116 queries. |
5 |
Correct |
1 ms |
292 KB |
Guessed the password with 105 queries. |
6 |
Correct |
3 ms |
200 KB |
Guessed the password with 199 queries. |
7 |
Correct |
27 ms |
464 KB |
Guessed the password with 3462 queries. |
8 |
Correct |
30 ms |
376 KB |
Guessed the password with 5035 queries. |
9 |
Correct |
63 ms |
504 KB |
Guessed the password with 6355 queries. |
10 |
Correct |
93 ms |
392 KB |
Guessed the password with 8715 queries. |
11 |
Correct |
156 ms |
388 KB |
Guessed the password with 13650 queries. |
12 |
Correct |
106 ms |
392 KB |
Guessed the password with 12460 queries. |
13 |
Correct |
146 ms |
392 KB |
Guessed the password with 14407 queries. |
14 |
Correct |
108 ms |
508 KB |
Guessed the password with 13973 queries. |
15 |
Correct |
184 ms |
396 KB |
Guessed the password with 15077 queries. |
16 |
Correct |
148 ms |
536 KB |
Guessed the password with 14160 queries. |
17 |
Correct |
181 ms |
520 KB |
Guessed the password with 16061 queries. |
18 |
Correct |
178 ms |
400 KB |
Guessed the password with 15212 queries. |
19 |
Correct |
153 ms |
396 KB |
Guessed the password with 16417 queries. |
20 |
Correct |
163 ms |
516 KB |
Guessed the password with 14253 queries. |
21 |
Correct |
171 ms |
400 KB |
Guessed the password with 16875 queries. |
22 |
Correct |
125 ms |
524 KB |
Guessed the password with 15478 queries. |
23 |
Correct |
234 ms |
540 KB |
Guessed the password with 23705 queries. |
24 |
Correct |
166 ms |
612 KB |
Guessed the password with 22240 queries. |
25 |
Correct |
220 ms |
544 KB |
Guessed the password with 23865 queries. |
26 |
Correct |
260 ms |
540 KB |
Guessed the password with 23349 queries. |
27 |
Correct |
263 ms |
520 KB |
Guessed the password with 23792 queries. |
28 |
Correct |
260 ms |
592 KB |
Guessed the password with 23049 queries. |
29 |
Correct |
136 ms |
512 KB |
Guessed the password with 23871 queries. |
30 |
Correct |
225 ms |
632 KB |
Guessed the password with 22509 queries. |