# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1111190 | sofija6 | 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 <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <stdlib.h>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
string Merge(string a,string b)
{
int posa=0,posb=0;
string ans="";
while (posa<a.size() && posb<b.size())
{
string d="";
d+=a[posa];
for (int j=posb;j<b.size();j++)
d+=(char)b[j];
if (query(d)==(int)d.size())
{
ans+=a[posa];
posa++;
}
else
{
ans+=b[posb];
posb++;
}
}
for (int i=posa;i<a.size();i++)
ans+=a[i];
for (int i=posb;i<b.size();i++)
ans+=b[i];
return ans;
}
bool Cmp(string a,string b)
{
return a.size()<b.size();
}
string guess(int n, int s)
{
vector<string> cur,cur1;
for (int i=0;i<s;i++)
{
string ss="";
for (int j=0;j<n;j++)
ss+=(char)('a'+i);
int len=query(ss);
if (len)
{
ss="";
for (int j=0;j<len;j++)
ss+=(char)('a'+i);
cur.push_back(ss);
}
}
while (cur.size()!=1)
{
sort(cur.begin(),cur.end(),Cmp);
string a=cur[0],b=cur[1];
for (int i=2;i<cur.size();i++)
cur1.push_back(cur[i]);
cur=cur1;
cur1.clear();
cur.push_back(Merge(a,b));
}
return cur[0];
}