#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
using namespace std;
int query(string q);
int mxn=2e5+5;
int k;
string mrg(string a,string b){
string x;
for(int i=0;i<b.size();i++){
for(int j=0;j<=a.size();j++){
x=a;
x.insert(x.begin()+j,b[i]);
if(query(x)==x.size()){
a=x;
break;
}
}
}
//cout<<a<<endl;
return a;
}
string guess(int n, int kx){
char c='a';
int k=kx;
priority_queue<string,vector<string>,greater<string>>q;
for(int id=1;id<=k;id++){
string s="";
for(int j=1;j<=n;j++){
s+=c;
}
int x=query(s);
s="";
//cout<<x<<endl;
for(int i=1;i<=x;i++){
s+=c;
}
//cout<<s<<endl;
if(s.size()>0){
q.push(s);
}
c++;
}
while(q.size()>1){
string a=q.top();
q.pop();
string b=q.top();
q.pop();
string x=mrg(a,b);
q.push(x);
}
return q.top();
}
Compilation message
password.cpp: In function 'std::string mrg(std::string, std::string)':
password.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int i=0;i<b.size();i++){
| ~^~~~~~~~~
password.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int j=0;j<=a.size();j++){
| ~^~~~~~~~~~
password.cpp:23:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | if(query(x)==x.size()){
| ~~~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 76 queries. |
2 |
Correct |
2 ms |
208 KB |
Guessed the password with 187 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Guessed the password with 451 queries. |
2 |
Correct |
4 ms |
208 KB |
Guessed the password with 716 queries. |
3 |
Correct |
1 ms |
208 KB |
Guessed the password with 103 queries. |
4 |
Correct |
13 ms |
208 KB |
Guessed the password with 2941 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
353 ms |
296 KB |
Could not guess the password with 50000 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 76 queries. |
2 |
Correct |
2 ms |
208 KB |
Guessed the password with 187 queries. |
3 |
Correct |
4 ms |
208 KB |
Guessed the password with 451 queries. |
4 |
Correct |
4 ms |
208 KB |
Guessed the password with 716 queries. |
5 |
Correct |
1 ms |
208 KB |
Guessed the password with 103 queries. |
6 |
Correct |
13 ms |
208 KB |
Guessed the password with 2941 queries. |
7 |
Incorrect |
353 ms |
296 KB |
Could not guess the password with 50000 queries. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 76 queries. |
2 |
Correct |
2 ms |
208 KB |
Guessed the password with 187 queries. |
3 |
Correct |
4 ms |
208 KB |
Guessed the password with 451 queries. |
4 |
Correct |
4 ms |
208 KB |
Guessed the password with 716 queries. |
5 |
Correct |
1 ms |
208 KB |
Guessed the password with 103 queries. |
6 |
Correct |
13 ms |
208 KB |
Guessed the password with 2941 queries. |
7 |
Incorrect |
353 ms |
296 KB |
Could not guess the password with 50000 queries. |
8 |
Halted |
0 ms |
0 KB |
- |