시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB130973953316431.924%

문제

N+1개의 I와 N개의 O로 이루어져 있으면, IO이 교대로 나오는 문자열을 PN이라고 한다.

  • P1 IOI
  • P2 IOIOI
  • P3 IOIOIOI
  • PN IOIOI...OI (O가 N개)

IO로만 이루어진 문자열 S와 정수 N이 주어졌을 때, S안에 PN이 몇 군데 포함되어 있는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 N이 주어진다. 둘째 줄에는 S의 길이 M이 주어지며, 셋째 줄에 S가 주어진다.

출력

S에 PN이 몇 군데 포함되어 있는지 출력한다.

제한

  • 1 ≤ N ≤ 1,000,000
  • 2N+1 ≤ M ≤ 1,000,000
  • S는 IO로만 이루어져 있다.

서브태스크

번호 배점 제한
1 50

N ≤ 100, M ≤ 10 000.

2 50

추가적인 제약 조건이 없다.

예제 입력 1

1
13
OOIOIOIOIIOII

예제 출력 1

4
  • OOIOIOIOIIOII
  • OOIOIOIOIIOII
  • OOIOIOIOIIOII
  • OOIOIOIOIIOII

예제 입력 2

2
13
OOIOIOIOIIOII

예제 출력 2

2
  • OOIOIOIOIIOII
  • OOIOIOIOIIOII
W3sicHJvYmxlbV9pZCI6IjU1MjUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJJT0lPSSIsImRlc2NyaXB0aW9uIjoiPHA+TisxXHVhYzFjXHVjNzU4IDxjb2RlPkk8XC9jb2RlPlx1YzY0MCBOXHVhYzFjXHVjNzU4IDxjb2RlPk88XC9jb2RlPlx1Yjg1YyBcdWM3NzRcdWI4ZThcdWM1YjRcdWM4MzggXHVjNzg4XHVjNzNjXHViYTc0LCA8Y29kZT5JPFwvY29kZT5cdWM2NDAgPGNvZGU+TzxcL2NvZGU+XHVjNzc0IFx1YWQ1MFx1YjMwMFx1Yjg1YyBcdWIwOThcdWM2MjRcdWIyOTQgXHViYjM4XHVjNzkwXHVjNWY0XHVjNzQ0IFA8c3ViPk48XC9zdWI+XHVjNzc0XHVi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jXHU1MWZhXHU1MjliXHUzMDZmIDIgXHUzMDY3XHUzMDQyXHUzMDhiXHVmZjBlPFwvcD5cclxuXHJcbjx1bD5cclxuXHQ8bGk+PGNvZGU+T088dT5JT0lPSTxcL3U+T0lJT0lJPFwvY29kZT48XC9saT5cclxuXHQ8bGk+PGNvZGU+T09JTzx1PklPSU9JPFwvdT5JT0lJPFwvY29kZT48XC9saT5cclxuPFwvdWw+XHJcblxyXG48cD5cdTU2ZjMgMyBOID0gMlx1ZmYwY1MgXHUzMDRjIDxjb2RlPk9PSU9JT0lPSUlPSUk8XC9jb2RlPiBcdTMwNmVcdTU4MzRcdTU0MDhcdTMwNmVcdTRmOGI8XC9wPlxyXG4ifV0=

출처

Olympiad > Japanese Olympiad in Informatics > JOI 2013 P4번

Olympiad > Japanese Olympiad in Informatics > JOI 2009 1번

Olympiad > Japanese Olympiad in Informatics > JOI 2014 P4번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: hist0613

채점 및 기타 정보

  • 예제는 채점하지 않는다.