# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464490 | fuad27 | Password (RMI18_password) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vii vector < pair < int, int >>
#define vi vector < int >
#define vl vector < long long >
#define vll vector < pair < long long, long long >>
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define FIO ios_base::sync_with_stdio(0);
cin.tie(0);
#define start int tt;
cin >> tt;
rep(testcase, 1, tt)
#define print(k) cout << "Case #" << testcase << ": " << k << "\n";
#define endl "\n"
#define DEBUG(k) cerr << k << "\n";
int query(string str);
int f[30];
string guess(int n, int s) {
string res;
rep(i, 0, s - 1) {
char c = 'a' + i;
string q(n, c);
f[i] = query(q);
}
int st = 0;
rep(i, 0, s - 1) {
if (f[i] > 0) {
char c = i + 'a';
rep(j, 1, f[i]) {
res += c;
}
st = i + 1;
break;
}
}
int curlen = res.length();
rep(i, st, s - 1) {
char c = i + 'a';
string ch;
ch += c;
int pos = -1;
string q;
while (true) {
if (f[i] == 0) break;
if (pos == -1) {
q = ch + res;
} else {
q = res.substr(0, pos + 1) + ch;
q += res.substr(pos + 1, curlen - pos - 1);
}
if (query(q) == curlen + 1) {
res = q;
curlen++;
pos++;
f[i]--;
} else {
pos++;
}
if (pos >= curlen) break;
}
}
return res;
}