# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476097 | stefantaga | Password (RMI18_password) | C++14 | 251 ms | 608 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>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <stdlib.h>
#include <assert.h>
using namespace std;
int query(string str);
string sol,acum;
int n,s;
char litera[105];
bool intreaba(char litera,int x)
{
string acum;
for (int i=1;i<=x;i++)
{
acum.push_back(litera);
}
if (query(acum)==x)
{
return 1;
}
return 0;
}
int fr[105],poz,pozitie,inainte[1005],ceau[5005];
char finalsol[5005];
bool compare (int a,int b)
{
return fr[a]>fr[b];
}
string divide(int st,int dr)
{
if (st==dr)
{
string acum;
for (int i=1;i<=fr[st];i++)
{
acum.push_back(litera[st]);
}
return acum;
}
int mij=(st+dr)/2;
string stanga=divide(st,mij);
string dreapta=divide(mij+1,dr);
string panaacum;
while (stanga.size()&&dreapta.size())
{
string ceintreb = panaacum+stanga[0]+dreapta;
if (query(ceintreb)==ceintreb.size())
{
panaacum+=stanga[0];
stanga.erase(stanga.begin());
}
else
{
panaacum+=dreapta[0];
dreapta.erase(dreapta.begin());
}
}
panaacum+=stanga;
panaacum+=dreapta;
return panaacum;
}
string guess (int N,int S)
{
int i,st,dr,mij,sol,j,k;
n=N;s=S;
for (i=1;i<=s;i++)
{
litera[i]=(char(i+96));
st=1;
dr=n;
sol=0;
while (st<=dr)
{
mij=(st+dr)/2;
if (intreaba(litera[i],mij)==1)
{
sol=mij;
st=mij+1;
}
else
{
dr=mij-1;
}
}
fr[i]=sol;
}
string salut=divide(1,s);
return salut;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |