카테고리 없음

회문의회문

가은(JANE) 2024. 11. 19. 20:25

#Problem
https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&problemLevel=3&contestProbId=AY2hjCWKbykDFATh&categoryId=AY2hjCWKbykDFATh&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=1

SW Expert Academy

swexpertacademy.com

#Think
조건문 덕지덕지면 뭐든 풀 수 있다!
#Code
T=int(input())

for tc in range(1,T+1):
    s = list(input())
    #1번 조건
    re_s = s[::-1]
    n= len(s)
    number = int((n-1)/2)

    if s == re_s:
        # 2번 조건
        second = s[0:number]
        resecond = second[::-1]
        
        if second == resecond:
         #3번 조건
            third = s[n-number:]
            rethird = third[::-1]
            
            if third == rethird:
                print(f"#{tc} YES")
            else: print(f"#{tc} NO")
        else : print(f"#{tc} NO")
    else: print(f"#{tc} NO")