题解 | 查找兄弟单词
def is_brother(word, target):
if len(word) != len(target) or word == target:
return False
return sorted(word) == sorted(target)
# Read input
n, *words, x, k = input().split()
n = int(n)
k = int(k)
# Find brother words
brother_words = []
for word in words:
if is_brother(word, x):
brother_words.append(word)
# Sort and output
brother_words.sort()
print(len(brother_words))
if brother_words and k <= len(brother_words):
print(brother_words[k-1])
SHEIN公司福利 847人发布