# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
722696 | groshi | 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;
priority_queue<pair<int,string> > kolejka;
string marge(string a,string b)
{
string wypisz="";
int l=0,r=0;
while(l<a.length() || r<b.length())
{
if(l==a.length())
{
wypisz+=b[r];
r++;
continue;
}
if(r==b.length())
{
wypisz+=a[l];
l++;
continue;
}
string posiadam="";
for(int i=l;i<a.length();i++)
posiadam+=a[i];
int ile=query(wypisz+b[r]+posiadam);
if(ile==wypisz.length()+1+posiadam.length())
{
wypisz+=b[r];
r++;
continue;
}
else{
wypisz+=a[l];
l++;
continue;
}
}
return wypisz;
}
string guess(int n,int s)
{
for(int i=0;i<s;i++)
{
string pom="";
for(int j=1;j<=n;j++)
pom+=(char)('a'+i);
int ile=query(pom);
string mam="";
for(int j=1;j<=ile;j++)
mam+=(char)('a'+i);
if(ile!=0)
kolejka.push({-ile,mam});
}
while(kolejka.size()>=2)
{
auto para1=kolejka.top();
kolejka.pop();
auto para2=kolejka.top();
kolejka.pop();
string mam=marge(para1.second,para2.second);
kolejka.push({-mam.length(),mam});
}
return kolejka.top().second;
}