지나가던 개발자

[Python] 백준 8892번(팰린드롬) 문제 풀이 본문

PS/Python

[Python] 백준 8892번(팰린드롬) 문제 풀이

KwonYongHyeon 2022. 11. 2. 17:57

 

from itertools import permutations

def is_palindrome(a):
    return a == a[::-1]

for i in range(int(input())):
    tango = []
    for j in range(int(input())):
        tango.append(input())
    printed = False
    for j in permutations(tango, 2):
        if is_palindrome("".join(j)):
            printed = True
            print("".join(j))
            break
    if not printed:
        print(0)

 

메모리 초과가 떠도 그닥 이상치 않다고 생각하고 있었는데 맞았다.

Comments