-
[9996] 한국이 그리울 땐 서버에 접속하지 (Python)[Python] 알고리즘/Silver 2021. 11. 4. 17:16
[문제]
https://www.acmicpc.net/problem/9996
알고리즘 분류는 문자열, 브루트포스 알고리즘, 정규 표현식 입니다.
[파일의 시작]*[파일의 끝]으로 이루어져 있고, '*'를 기준으로 나눠줍니다.
1 abcd*cdef abcdef
이 예제의 경우, abcd와 cdef가 겹치므로 NE를 출력해야 합니다.
[코드]
import sys N = int(sys.stdin.readline()) pt = sys.stdin.readline().rstrip().split("*") front = len(pt[0]) back = len(pt[1]) for i in range(N): st = sys.stdin.readline().rstrip() st_front = st[:front] st = st[front:] st_back = st[len(st) - back :] if len(st) == 1: print("NE") elif st_front == pt[0] and st_back == pt[1]: print("DA") else: print("NE")
'[Python] 알고리즘 > Silver' 카테고리의 다른 글
[18115] 카드 놓기 (Python) (0) 2021.11.08 [13414] 수강신청 (Python) (0) 2021.11.05 [1900] 레슬러 (Python) (0) 2021.11.03 [5648] 역원소 정렬 (Python) (0) 2021.11.02 [1935] 후위 표기식2 (Python) (0) 2021.11.01