지나가던 개발자
[Python] 백준 8892번(팰린드롬) 문제 풀이 본문
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)
메모리 초과가 떠도 그닥 이상치 않다고 생각하고 있었는데 맞았다.
'PS > Python' 카테고리의 다른 글
[Python] 백준 10826번(피보나치 수 4) 문제 풀이 (0) | 2022.11.04 |
---|---|
[Python] 백준 4821번(페이지 세기) 문제 풀이 (0) | 2022.11.03 |
[Python] 백준 2941번(크로아티아 알파벳) 문제 풀이 (0) | 2022.11.01 |
[Python] 백준 5800번(성적 통계) 문제 풀이 (0) | 2022.10.31 |
[Python] 백준 2167번(2차원 배열의 합) 문제 풀이 (0) | 2022.10.30 |
Comments