Notice
Recent Posts
Recent Comments
Link
«   2025/10   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

DANIELOGIC

[Python] 백준 8892번 팰린드롬 본문

Algorithm/백준

[Python] 백준 8892번 팰린드롬

daniel; 2024. 6. 24. 02:38

[Python] 백준 8892번 팰린드롬

https://www.acmicpc.net/problem/8892

문제

코드

t1 = int(input())
for i in range(t1):
    l=[]
    t2 = int(input())
    for x in range(t2):
        l.append(input())
    dap = 0
    for y in range(t2):
        for x in range(t2):
            if x != y:
                a = l[y]+l[x]
                s = 0
                for i in range(0,len(a)//2):
                    if a[i] != a[-i-1]:
                        s = 1
                if s == 0:
                    dap = a
    if dap != 0:
        print(dap)
    else:
        print(0)

리뷰

과거에 작성했던 팰린드롬 판별 코드를 다시 사용했다.

if a == a[::-1] 이런식으로 판별하는 방법도 존재한다.

'Algorithm > 백준' 카테고리의 다른 글

[Python] 백준 10991번 별 찍기 - 16  (0) 2024.06.24
[Python] 백준 2921번 도미노  (0) 2024.06.24
[Python] 백준 2444번 별 찍기 - 7  (0) 2024.06.24
[Python] 백준 1408번 24  (0) 2024.06.23
[Python] 백준 5635번 생일  (0) 2024.06.23