#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define rrep(i, a, b) for(ll i = b-1; i >= ll(a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
int query(string str);
string combine(string a, string b){
string ans = "";
//cout<<a<<" "<<b<<endl;
while(b.size()&&a.size()){
if(query(ans+b[0]+a)==sz(ans)+sz(a)+1){
ans += b[0];
b.erase(b.begin());
} else {
ans += a[0];
a.erase(a.begin());
}
}
ans+=b;
ans+=a;
//cout<<ans<<endl;
return ans;
}
string guess(int n, int s){
vector<string> v;
rep(i,0,s) {
v.push_back(string(query(string(n,'a'+i)),'a'+i));
//cout<<v.back()<<endl;
}
while(v.size()>=2){
vector<string> newV;
rep(i,0,v.size()/2) newV.push_back(combine(v[2*i],v[2*i+1]));
if(v.size()%2==1) newV.push_back(v.back());
v = newV;
}
return v[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Guessed the password with 60 queries. |
2 |
Correct |
6 ms |
280 KB |
Guessed the password with 102 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Guessed the password with 48 queries. |
2 |
Correct |
6 ms |
376 KB |
Guessed the password with 116 queries. |
3 |
Correct |
6 ms |
248 KB |
Guessed the password with 91 queries. |
4 |
Correct |
7 ms |
248 KB |
Guessed the password with 198 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
376 KB |
Guessed the password with 3472 queries. |
2 |
Correct |
57 ms |
248 KB |
Guessed the password with 5024 queries. |
3 |
Correct |
70 ms |
376 KB |
Guessed the password with 6859 queries. |
4 |
Correct |
71 ms |
324 KB |
Guessed the password with 9074 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Guessed the password with 60 queries. |
2 |
Correct |
6 ms |
280 KB |
Guessed the password with 102 queries. |
3 |
Correct |
5 ms |
504 KB |
Guessed the password with 48 queries. |
4 |
Correct |
6 ms |
376 KB |
Guessed the password with 116 queries. |
5 |
Correct |
6 ms |
248 KB |
Guessed the password with 91 queries. |
6 |
Correct |
7 ms |
248 KB |
Guessed the password with 198 queries. |
7 |
Correct |
38 ms |
376 KB |
Guessed the password with 3472 queries. |
8 |
Correct |
57 ms |
248 KB |
Guessed the password with 5024 queries. |
9 |
Correct |
70 ms |
376 KB |
Guessed the password with 6859 queries. |
10 |
Correct |
71 ms |
324 KB |
Guessed the password with 9074 queries. |
11 |
Correct |
159 ms |
376 KB |
Guessed the password with 13607 queries. |
12 |
Correct |
113 ms |
376 KB |
Guessed the password with 11101 queries. |
13 |
Correct |
163 ms |
504 KB |
Guessed the password with 14700 queries. |
14 |
Correct |
142 ms |
460 KB |
Guessed the password with 13486 queries. |
15 |
Correct |
149 ms |
504 KB |
Guessed the password with 14842 queries. |
16 |
Correct |
136 ms |
452 KB |
Guessed the password with 13539 queries. |
17 |
Correct |
174 ms |
376 KB |
Guessed the password with 16237 queries. |
18 |
Correct |
139 ms |
376 KB |
Guessed the password with 13757 queries. |
19 |
Correct |
170 ms |
452 KB |
Guessed the password with 16675 queries. |
20 |
Correct |
125 ms |
504 KB |
Guessed the password with 12435 queries. |
21 |
Correct |
189 ms |
376 KB |
Guessed the password with 17140 queries. |
22 |
Correct |
134 ms |
504 KB |
Guessed the password with 14500 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Guessed the password with 60 queries. |
2 |
Correct |
6 ms |
280 KB |
Guessed the password with 102 queries. |
3 |
Correct |
5 ms |
504 KB |
Guessed the password with 48 queries. |
4 |
Correct |
6 ms |
376 KB |
Guessed the password with 116 queries. |
5 |
Correct |
6 ms |
248 KB |
Guessed the password with 91 queries. |
6 |
Correct |
7 ms |
248 KB |
Guessed the password with 198 queries. |
7 |
Correct |
38 ms |
376 KB |
Guessed the password with 3472 queries. |
8 |
Correct |
57 ms |
248 KB |
Guessed the password with 5024 queries. |
9 |
Correct |
70 ms |
376 KB |
Guessed the password with 6859 queries. |
10 |
Correct |
71 ms |
324 KB |
Guessed the password with 9074 queries. |
11 |
Correct |
159 ms |
376 KB |
Guessed the password with 13607 queries. |
12 |
Correct |
113 ms |
376 KB |
Guessed the password with 11101 queries. |
13 |
Correct |
163 ms |
504 KB |
Guessed the password with 14700 queries. |
14 |
Correct |
142 ms |
460 KB |
Guessed the password with 13486 queries. |
15 |
Correct |
149 ms |
504 KB |
Guessed the password with 14842 queries. |
16 |
Correct |
136 ms |
452 KB |
Guessed the password with 13539 queries. |
17 |
Correct |
174 ms |
376 KB |
Guessed the password with 16237 queries. |
18 |
Correct |
139 ms |
376 KB |
Guessed the password with 13757 queries. |
19 |
Correct |
170 ms |
452 KB |
Guessed the password with 16675 queries. |
20 |
Correct |
125 ms |
504 KB |
Guessed the password with 12435 queries. |
21 |
Correct |
189 ms |
376 KB |
Guessed the password with 17140 queries. |
22 |
Correct |
134 ms |
504 KB |
Guessed the password with 14500 queries. |
23 |
Correct |
234 ms |
488 KB |
Guessed the password with 24024 queries. |
24 |
Correct |
240 ms |
528 KB |
Guessed the password with 22707 queries. |
25 |
Correct |
262 ms |
564 KB |
Guessed the password with 24097 queries. |
26 |
Correct |
280 ms |
584 KB |
Guessed the password with 24565 queries. |
27 |
Correct |
257 ms |
552 KB |
Guessed the password with 24137 queries. |
28 |
Correct |
251 ms |
536 KB |
Guessed the password with 23568 queries. |
29 |
Correct |
237 ms |
600 KB |
Guessed the password with 24180 queries. |
30 |
Correct |
261 ms |
572 KB |
Guessed the password with 22391 queries. |