# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333451 | ijxjdjd | Password (RMI18_password) | C++14 | 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 string str;
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long, long> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FR(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define RF(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
string ori;
//int query(str s) {
// int cur = 0;
// for (int i = 0; i < ori.length() && cur < s.length(); i++) {
// if (ori[i] == s[cur]) {
// cur++;
// }
// }
// return cur;
//}
str guess(int n, int s) {
vector<str> vec(s);
FR(i, s) {
str base = "";
FR(j, n) {
base += (char)(i + 'a');
}
vec[i] = base.substr(0, query(base));
}
sort(vec.begin(), vec.end(), [ ](const string& lhs, const string& rhs){
return (lhs.length() < rhs.length());
});
string cur = "";
RF(i, s) {
string next = vec[i];
FR(j, vec[i].length()) {
int low = 0;
int high = cur.length();
while (low < high) {
int mid = (low + high + 1)/2;
string cpy = vec[i];
cpy.insert(j, cur.substr(0, mid));
if (query(cpy) == cpy.length()) {
low = mid;
}
else {
high = mid-1;
}
}
vec[i].insert(j, cur.substr(0, low));
cur = cur.substr(low);
j += low;
}
vec[i] += cur;
cur = vec[i];
}
return cur;
}
//int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// cin >> ori;
// cout << guess(ori.size(), 26) << endl;
//}