头条笔试 双生词 40% PYTHON
import sys t = int(raw_input()) data = [] for i in range(t): n = int(raw_input()) temp = [] for j in range(n): temp.append(sys.stdin.readline().strip()) data.append(temp) def sub(A, B): return len(A) == len(B) and B in A + A def sub2(num): for j in range(len(num)-1): for h in range(j+1, len(num)): if sub(num[j], num[h]) or sub(num[j], num[h][::-1]): return True else: return False for i in range(t): if sub2(data[i]): print('Yeah') else: print('Sad')
求大佬指导
#阿里巴巴##高德##机器学习#