# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791670 | anton | 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;
int query(string q);
string uni(char c, int l){
string r;
for(int i = 0; i<l; i++){
r.push_back(c);
}
return r;
}
string merge(string a, string b){
if(a.size()<b.size()){
return merge(b, a);
}
int p = 0;
int nb_ins= 0;
while(p<=a.size()&& nb_ins<b.size()){
string r2 = a;
r2.insert(r2.begin()+ p, b[nb_ins]);
if(query(r2) == r2.size()){
swap(a, r2);
nb_ins++;
}
p++;
}
return a;
}
vector<int> oc;
string dpr(int lt, int rt){
if(lt == rt){
return uni(lt+'a', oc[lt]);
}
else{
int mid = (lt+rt)/2;
return merge(dpr(lt, mid), dpr(mid+1, rt));
}
}
string guess(int n, int s){
pii best;
string r;
oc.resize(s);
for(int i = 0; i<s; i++){
string a;
int l =0;
char c= 'a'+i;
oc[i] = query(uni(c, n));
//cout<<c<<" "<<oc[i]<<endl;
if(oc[i]>best.first){
best.first = oc[i];
best.second = i;
}
}
r = dpr(0, s-1);
return r;
}