# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985242 | bachhoangxuan | 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;
string guess(int n,int s){
function<string(int,int)> dnc = [&](int l,int r){
if(l==r) return string(query(string(n,'a'+l)),'a'+l);
int mid=(l+r)>>1,i,j;
string lt=dnc(l,mid),rt=dnc(mid+1,r),res;
for(i=0,j=0;i<(int)lt.size() && j<(int)rt.size();){
string cur=res+lt[i]+rt.substr(j);
if(query(cur)==(int)cur.size()) res+=lt[i++];
else res+=rt[j++];
}
if(i==(int)lt.size()) res+=rt.substr(j);
else res+=lt.substr(i);
return res;
};
return dnc(0,s-1);
}