# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
722696 | groshi | Password (RMI18_password) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}