728x90
T = int(input())
result=[]
for i in range(T):
k = int(input())
word=[]
for i in range(k):
word.append(input())
a=[]
b=[]
for i in range(k):
for j in range(k):
if(i!=j):
x = word[i]
y = word[j]
a.append(x+y)
b.append(y[::-1]+x[::-1])
cnt=0
for i in range(len(a)):
if a[i]==b[i]:
result.append(a[i])
cnt+=1
break
if cnt==0:
result.append("0")
for i in range(len(result)):
print(result[i])
number = int(input())
save = []
for i in range(number):
a = int(input())
palin = []
for j in range(a):
b = input()
palin.append(b)
go = True
for j in range(a):
for k in range(a):
if j==k:
continue
word=palin[j]+palin[k]
reverse = word[::-1]
if word == reverse:
save.append(word)
go = False
break
if go == False:
break
if go == True:
save.append("0")
for i in range(len(save)):
print(save[i])
반응형
'전.py' 카테고리의 다른 글
백준 1781 컵라면(실패) (0) | 2020.12.17 |
---|---|
백준 1700 멀티탭 스케줄링(실패) (0) | 2020.12.17 |
백준 1284 집 주소 (0) | 2020.12.17 |
백준 1439 뒤집기 (0) | 2020.12.17 |
백준 17204 죽음의 게임 (0) | 2020.12.17 |