#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool isBrother(string a, string b) {
if((a == b) || (a.size() != b.size()))
return false;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if(a == b)
return true;
else return false;
}
int main() {
int n, m;
string s, t;
while(cin >> n) {
vector<string> dor;
for(int i = 0; i < n; i++) {
cin >> s;
dor.push_back(s);
}
sort(dor.begin(), dor.end());
cin >> t;
cin >> m;
int counts = 0;
string tmp;
for(int i = 0; i < n; i++) {
if(isBrother(t, dor[i])) {
counts++;
if(counts == m)
tmp = dor[i];
}
}
if(!dor.empty())
cout << counts << endl;
if(counts >= m)
cout << tmp << endl;
dor.clear();
}
return 0;
}
查找兄弟单词
最新推荐文章于 2020-03-03 11:38:37 发布