#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
//#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;
const int mod=1e9+7;
const int modp=1999999973;
const int modulo=998244353;
int query(string str);
string guess(int n,int s){
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
srand(chrono::steady_clock::now().time_since_epoch().count());
vector<char>tz;
for(int i=0;i<s;i++){
tz.push_back(i+'a');
}
string ans;
while(ans.size()!=n){
for(int i=0;i<=ans.size();i++){
random_shuffle(all(tz));
for(int j=0;j<tz.size();j++){
string ask = ans.substr(0,i) + tz[j] + ans.substr(i,ans.size()-i);
if(query(ask)==ans.size()+1){
ans=ans.substr(0,i) + tz[j] +ans.substr(i,ans.size()-i);
break;
}
}
}
}
return ans;
}
Compilation message
password.cpp: In function 'std::__cxx11::string guess(int, int)':
password.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(ans.size()!=n){
~~~~~~~~~~^~~
password.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<=ans.size();i++){
~^~~~~~~~~~~~
password.cpp:36:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<tz.size();j++){
~^~~~~~~~~~
password.cpp:38:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(query(ask)==ans.size()+1){
~~~~~~~~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Guessed the password with 484 queries. |
2 |
Correct |
21 ms |
384 KB |
Guessed the password with 1487 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Guessed the password with 109 queries. |
2 |
Correct |
7 ms |
384 KB |
Guessed the password with 282 queries. |
3 |
Correct |
6 ms |
384 KB |
Guessed the password with 198 queries. |
4 |
Correct |
23 ms |
384 KB |
Guessed the password with 1341 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
342 ms |
384 KB |
Could not guess the password with 50000 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Guessed the password with 484 queries. |
2 |
Correct |
21 ms |
384 KB |
Guessed the password with 1487 queries. |
3 |
Correct |
6 ms |
384 KB |
Guessed the password with 109 queries. |
4 |
Correct |
7 ms |
384 KB |
Guessed the password with 282 queries. |
5 |
Correct |
6 ms |
384 KB |
Guessed the password with 198 queries. |
6 |
Correct |
23 ms |
384 KB |
Guessed the password with 1341 queries. |
7 |
Incorrect |
342 ms |
384 KB |
Could not guess the password with 50000 queries. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Guessed the password with 484 queries. |
2 |
Correct |
21 ms |
384 KB |
Guessed the password with 1487 queries. |
3 |
Correct |
6 ms |
384 KB |
Guessed the password with 109 queries. |
4 |
Correct |
7 ms |
384 KB |
Guessed the password with 282 queries. |
5 |
Correct |
6 ms |
384 KB |
Guessed the password with 198 queries. |
6 |
Correct |
23 ms |
384 KB |
Guessed the password with 1341 queries. |
7 |
Incorrect |
342 ms |
384 KB |
Could not guess the password with 50000 queries. |
8 |
Halted |
0 ms |
0 KB |
- |