File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ N = int (input ())
2+ M = int (input ())
3+ S = input ()
4+
5+ IOI = 'I' + 'OI' * N
6+ length , cnt = len (IOI ), 0
7+
8+ for i in range (M - length + 1 ):
9+ A = S [i :i + length ]
10+ if A == IOI : cnt += 1
11+ print (cnt )
Original file line number Diff line number Diff line change 1+ # [ Silver I] IOIOI - 5525
2+
3+ [ 문제 링크] ( https://www.acmicpc.net/problem/5525 )
4+
5+ ### 성능 요약
6+
7+ 메모리: 109544 KB, 시간: 92 ms
8+
9+ ### 분류
10+
11+ 문자열
12+
13+ ### 제출 일자
14+
15+ 2025년 3월 4일 16:09:07
16+
17+ ### 문제 설명
18+
19+ <p >N+1개의 <code >I</code >와 N개의 <code >O</code >로 이루어져 있으면, <code >I</code >와 <code >O</code >이 교대로 나오는 문자열을 P<sub >N</sub >이라고 한다.</p >
20+
21+ <ul >
22+ <li>P<sub>1</sub> <code>IOI</code></li>
23+ <li>P<sub>2</sub> <code>IOIOI</code></li>
24+ <li>P<sub>3</sub> <code>IOIOIOI</code></li>
25+ <li>P<sub>N</sub> <code>IOIOI...OI</code> (<code>O</code>가 N개)</li>
26+ </ul >
27+
28+ <p ><code >I</code >와 <code >O</code >로만 이루어진 문자열 S와 정수 N이 주어졌을 때, S안에 P<sub >N</sub >이 몇 군데 포함되어 있는지 구하는 프로그램을 작성하시오.</p >
29+
30+ ### 입력
31+
32+ <p >첫째 줄에 N이 주어진다. 둘째 줄에는 S의 길이 M이 주어지며, 셋째 줄에 S가 주어진다.</p >
33+
34+ ### 출력
35+
36+ <p >S에 P<sub >N</sub >이 몇 군데 포함되어 있는지 출력한다.</p >
37+
You can’t perform that action at this time.
0 commit comments