题解 | #查找兄弟单词#
查找兄弟单词
https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,k;
string x;
cin>>n;
vector<string> arr;
for(int i=0;i<n;i++)
{
string tmp;
cin>>tmp;
arr.push_back(tmp);
}
cin>>x;
cin>>k;
vector<string> res;
int coun=0;
string xx=x;
sort(x.begin(),x.end());
for(auto &t:arr)
{
string tmp=t;
sort(tmp.begin(),tmp.end());
if(x==tmp&&xx!=t)
{
// auto it=find(res.begin(),res.end(),t);
// if(it!=res.end())
//continue;
;
coun++;
res.push_back(t);
}
}
cout<<coun<<endl;
sort(res.begin(),res.end());
if(k-1<res.size())
cout<<res[k-1];
return 0;
}
// 64 位输出请用 printf("%lld")

