#include <iostream>
#include <bits/stdc++.h>
#include<string>
#include<set>
#include<iterator>
using namespace std;
int s1, s2;
string p1, p2;
string megold="a";
int query(string str);
struct szov
{
string ir;
int hosz=0;
};
struct rendez{
bool operator()(szov const& a, szov const& b)
{
return a.hosz<b.hosz;
}
};
multiset<szov,rendez> ms1;
multiset<szov,rendez>::iterator itr;
szov proba;
string merging(string f1, string f2)
{
string a3="a";
string e1,e2;
string ossz;
/* while(!f1.empty() || !f2.empty())
{
if(f1.empty())
{
a3=a3+f2;
}
else if(f2.empty())
{
a3=a3+f1;
}
else{
e1=f1[0];
e2=f2[0];
ossz=a3+e1+f2;
s2=query(ossz);
if(s2==ossz.size())
{
a3=a3+e1;
f1.erase(f1.begin());
}
else{
a3=a3+e2;
f2.erase(f2.begin());
}
}
}*/
return a3;
}
string guess(int N, int S)
{
string help="aabcdefghijklmnopqrstuvwxyz";
string T[27]={};
for(int j=1;j<N+1;j++)
{
for(int i=1;i<S+1;i++)
{
T[i]=T[i]+help[i];
}
}
for(int i=1;i<S+1;i++)
{
s1=query(T[i]);
if(s1>0)
{
proba.hosz=s1;
proba.ir.clear();
for(int j=1;j<s1+1;j++)
{
proba.ir=proba.ir+help[i];
}
ms1.insert(proba);
}
}
while(ms1.size()>1)
{
itr=ms1.begin();
p1=(*itr).ir;
ms1.erase(itr);
itr=ms1.begin();
p2=(*itr).ir;
ms1.erase(itr);
proba.hosz=p1.size()+p2.size();
proba.ir=merging(p1,p2);
ms1.insert(proba);
}
if(ms1.size()==1)
{
itr=ms1.begin();
megold=(*itr).ir;
}
return megold;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Returned early from guess() after 16 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Returned early from guess() after 3 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
456 KB |
Returned early from guess() after 13 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Returned early from guess() after 16 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Returned early from guess() after 16 queries. |
2 |
Halted |
0 ms |
0 KB |
- |