# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201351 | theStaticMind | 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>
#define pb push_back
#define ii pair<int, int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int query(string s);
string merge(string a, string b){
int j = 0;
if(a.length() > b.length())swap(a, b);
for(int i = 0; i <= a.length() && j < b.length(); i++){
string w = a;
string::iterator itr = a.insert(a.begin() + i, b[j]);
if(query(a) == a.length()){
j++;
}
else {
a.erase(itr);
}
}
return a;
}
string guess(int n, int k){
vector<string> seg;
for(int i = 0; i < k; i++){
string s;
for(int j = 0; j < n; j++) s.pb('a' + i);
int l = query(s);
s.clear();
for(int j = 0; j < l; j++) s.pb('a' + i);
seg.pb(s);
}
while(seg.size() != 1){
vector<string> temp;
for(int i = 1; i < seg.size(); i += 2){
temp.pb(merge(seg[i - 1], seg[i]));
}
if(seg.size() % 2)temp.pb(seg.back());
swap(temp, seg);
}
return seg[0];
}