#include <bits/stdc++.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;
char finalsol[5005];
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;
}
for (i=1;i<=s;i++)
{
string acum;
for (poz=1;poz<=fr[i];poz++)
{
pozitie=0;
for (j=1;j<=s;j++)
{
if (j==i)
{
continue;
}
st=1;
dr=fr[j];
sol=0;
while (st<=dr)
{
mij=(st+dr)/2;
string copie=acum;
for (k=1;k<=mij;k++)
{
copie.push_back(litera[j]);
}
for (k=1;k<=fr[i]-poz+1;k++)
{
copie.push_back(litera[i]);
}
if (query(copie)==mij+fr[i])
{
sol=mij;
st=mij+1;
}
else
{
dr=mij-1;
}
}
pozitie+=sol;
}
finalsol[pozitie]=litera[i];
acum.push_back(litera[i]);
}
}
string solfin;
for (i=1;i<=n;i++)
{
solfin.push_back(finalsol[i]);
}
return solfin;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
200 KB |
Token "dgnlajkebfihoc |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
200 KB |
Token "bbbaaba |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
280 ms |
300 KB |
Token "lllllllllllllllllkkgflhgl |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
200 KB |
Token "dgnlajkebfihoc |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
200 KB |
Token "dgnlajkebfihoc |
2 |
Halted |
0 ms |
0 KB |
- |