<문제 링크>
https://www.acmicpc.net/problem/5525
<정답 코드>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import sys
input = sys.stdin.read
N = int(input().strip())
M = int(input().strip())
S = input().strip()
answer, i, count = 0, 0, 0
while i < (M - 2):
if S[i:i+3] == 'IOI':
i += 2
count += 1
if count == N:
answer += 1
count -= 1
else:
i += 1
count = 0
print(answer)
|
cs |
'프로그래밍 > Python' 카테고리의 다른 글
백준_python 9372번 상근이의 여행 (그래프, 트리) (0) | 2024.08.08 |
---|---|
백준_python 1926번 그림 (DFS, BFS) (0) | 2024.08.04 |
백준_python 1244번 스위치 켜고 끄기 (구현) (0) | 2024.08.02 |
백준_python 1149번 RGB거리 (DP) (0) | 2024.07.30 |
백준_python 11053번 가장 긴 증가하는 부분 수열 (DP) (0) | 2024.07.29 |