We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4ff138e commit d541100Copy full SHA for d541100
2 files changed
백준/Silver/5525. IOIOI/IOIOI.py
@@ -1,11 +1,20 @@
1
+import sys
2
+input = sys.stdin.readline
3
+
4
N = int(input())
5
M = int(input())
6
S = input()
7
-IOI = 'I' + 'OI' * N
-length, cnt = len(IOI), 0
8
+ans, i, cnt = 0, 0, 0
9
-for i in range(M - length + 1):
- A = S[i:i+length]
10
- if A == IOI: cnt += 1
11
-print(cnt)
+while i < (M-1):
+ if S[i:i+3] == "IOI":
12
+ i += 2
13
+ cnt += 1
14
+ if cnt == N:
15
+ ans += 1
16
+ cnt -= 1
17
+ else:
18
+ i += 1
19
+ cnt = 0
20
+print(ans)
백준/Silver/5525. IOIOI/README.md
@@ -4,15 +4,15 @@
### 성능 요약
-메모리: 109544 KB, 시간: 92 ms
+메모리: 112428 KB, 시간: 108 ms
### 분류
문자열
### 제출 일자
-2025년 3월 4일 16:09:07
+2025년 3월 4일 16:19:07
### 문제 설명
0 commit comments