Skip to content

Instantly share code, notes, and snippets.

@fardinabir
Created June 4, 2021 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fardinabir/092b7c845cacaa7d2cb3c9283b6e8248 to your computer and use it in GitHub Desktop.
Save fardinabir/092b7c845cacaa7d2cb3c9283b6e8248 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
#define mxs 100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define print_case printf("Case %lld: ",ts++)
using namespace std;
int arr[3005],brr[300005],n,m,cnt;
int main()
{
int t,k,a,b,d,x,y,i,q,j,l,s,c,ans,mx=INT_MIN,mn=INT_MAX,ts=1;
scanf("%d",&t);
getchar();
getchar();
string st;
vector <string> stv;
map <string,int> mps;
char ch[1000];
while(t--)
{
while(gets(ch) && ch[0]!='\0')
stv.push_back(ch);
sort(stv.begin(),stv.end(),[](string sta,string stb){return sta.size()<stb.size();});
for(i=0;i<stv.size()/2;i++)
{
j=stv.size()-i-1;
st=stv[i]+stv[j];
mps[st]++;
st=stv[j]+stv[i];
mps[st]++;
}
string anss;
int mx=-1;
for(auto xx=mps.begin();xx!=mps.end();xx++)
{
if(xx->second > mx)
{
mx=xx->second;
anss=xx->first;
}
}
cout<<anss<<endl;
if(t)
cout<<endl;
stv.clear();
mps.clear();
}
return 0;
}
/*
2
011
0111
01110
111
0111
10111
1100
0011
11
000011
110
00011
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment