/// Zengy MANGA
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x,y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
using ll = long long;
using ii = pair<int,int>;
using ull = unsigned long long;
using db = long double;
const int N = 2e5+5, LG = 18, MOD = 998244353;
const long double PI = acos(-1);
int query(string s);
string guess(int n, int s) {
string lft = "";
string rt = "";
while(rt.size() + lft.size() != n) {
char cIndex = 'z' + 1;
// cout << rt << ' ' << lft << endl;
for(char c = 'a'; c < 'a' + s; c++) {
if(query(rt+string(1,c) + lft) > lft.size() + rt.size()) {
cIndex = c;
break;
}
}
if(cIndex == 'z' + 1) {
rt.pb(lft[0]);
lft.erase(lft.begin());
} else {
lft = string(1, cIndex) + lft;
}
}
return rt+lft;
}
Compilation message
password.cpp: In function 'std::string guess(int, int)':
password.cpp:33:34: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
33 | while(rt.size() + lft.size() != n) {
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~
password.cpp:37:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | if(query(rt+string(1,c) + lft) > lft.size() + rt.size()) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
200 KB |
Guessed the password with 315 queries. |
2 |
Correct |
7 ms |
200 KB |
Guessed the password with 736 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Guessed the password with 166 queries. |
2 |
Correct |
5 ms |
200 KB |
Guessed the password with 306 queries. |
3 |
Correct |
7 ms |
200 KB |
Guessed the password with 512 queries. |
4 |
Correct |
8 ms |
284 KB |
Guessed the password with 668 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
211 ms |
312 KB |
Guessed the password with 20159 queries. |
2 |
Correct |
218 ms |
536 KB |
Guessed the password with 29497 queries. |
3 |
Correct |
502 ms |
432 KB |
Guessed the password with 44816 queries. |
4 |
Incorrect |
461 ms |
436 KB |
Could not guess the password with 50000 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
200 KB |
Guessed the password with 315 queries. |
2 |
Correct |
7 ms |
200 KB |
Guessed the password with 736 queries. |
3 |
Correct |
2 ms |
200 KB |
Guessed the password with 166 queries. |
4 |
Correct |
5 ms |
200 KB |
Guessed the password with 306 queries. |
5 |
Correct |
7 ms |
200 KB |
Guessed the password with 512 queries. |
6 |
Correct |
8 ms |
284 KB |
Guessed the password with 668 queries. |
7 |
Correct |
211 ms |
312 KB |
Guessed the password with 20159 queries. |
8 |
Correct |
218 ms |
536 KB |
Guessed the password with 29497 queries. |
9 |
Correct |
502 ms |
432 KB |
Guessed the password with 44816 queries. |
10 |
Incorrect |
461 ms |
436 KB |
Could not guess the password with 50000 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
200 KB |
Guessed the password with 315 queries. |
2 |
Correct |
7 ms |
200 KB |
Guessed the password with 736 queries. |
3 |
Correct |
2 ms |
200 KB |
Guessed the password with 166 queries. |
4 |
Correct |
5 ms |
200 KB |
Guessed the password with 306 queries. |
5 |
Correct |
7 ms |
200 KB |
Guessed the password with 512 queries. |
6 |
Correct |
8 ms |
284 KB |
Guessed the password with 668 queries. |
7 |
Correct |
211 ms |
312 KB |
Guessed the password with 20159 queries. |
8 |
Correct |
218 ms |
536 KB |
Guessed the password with 29497 queries. |
9 |
Correct |
502 ms |
432 KB |
Guessed the password with 44816 queries. |
10 |
Incorrect |
461 ms |
436 KB |
Could not guess the password with 50000 queries. |