/// 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 ans = "";
int cur = 0;
for(char c = 'a'; c < 'a'+s; c++) {
for(int j = 0; j <= ans.size(); j++) {
if(query(ans.substr(0,j)+string(1,c)+ans.substr(j)) > cur) {
cur += 1;
ans = ans.substr(0,j)+string(1,c)+ans.substr(j);
break;
}
}
}
return ans;
}
Compilation message
password.cpp: In function 'std::string guess(int, int)':
password.cpp:34:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int j = 0; j <= ans.size(); j++) {
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 62 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 165 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Returned early from guess() after 3 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Returned early from guess() after 14 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 62 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 165 queries. |
3 |
Incorrect |
1 ms |
200 KB |
Returned early from guess() after 3 queries. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Guessed the password with 62 queries. |
2 |
Correct |
2 ms |
200 KB |
Guessed the password with 165 queries. |
3 |
Incorrect |
1 ms |
200 KB |
Returned early from guess() after 3 queries. |
4 |
Halted |
0 ms |
0 KB |
- |