문제) 백준 - 문자열 - 한국이 그리울 땐 서버에 접속하지
https://www.acmicpc.net/problem/9996
9996번: 한국이 그리울 땐 서버에 접속하지
총 N개의 줄에 걸쳐서, 입력으로 주어진 i번째 파일 이름이 패턴과 일치하면 "DA", 일치하지 않으면 "NE"를 출력한다. 참고로, "DA"는 크로아티어어로 "YES"를, "NE"는 "NO"를 의미한다.
www.acmicpc.net
Python 소스코드)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
input = sys.stdin.readline | |
N = int(input()) | |
f_str, b_str = input().split('*') | |
def solve(s): | |
if f_str == s[:len(f_str)] and b_str == s[-len(b_str):] and len(f_str + b_str) <= len(s): | |
return True | |
else: | |
return False | |
for i in range(N): | |
s = input() | |
if solve(s): | |
print("DA") | |
else: | |
print("NE") |
반응형
'PS(Problem Solving) > 백준_BOJ' 카테고리의 다른 글
[백준] 1251번 - 단어 나누기 (Python) 문제 및 풀이 (0) | 2022.03.04 |
---|---|
[백준] 14430번 - 자원 캐기 (C++) 문제 및 풀이 (0) | 2022.03.04 |
[백준] 22943번 - 수 (Python) 문제 및 풀이 (0) | 2022.03.02 |
[백준] 18405번 - 경제적 전염 (C++) 문제 및 풀이 (0) | 2022.03.02 |
[백준] 17609번 - 회문 (C++) 문제 및 풀이 (0) | 2022.03.01 |
댓글