[BOJ] 5525 IOIOI

Time Lapse :NONE

5525.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <memory.h>

using namespace std;

#define MAXSIZE 100
long long dp[MAXSIZE][2];
int n,m;
string s, comp;
long long ans=0;

int main(void)
{
cin>>n>>m>>s;
for(int i=0;i<m;i++)
{
if(s[i]=='O')
continue;
if(s[i+1]=='O'&&s[i+2]=='I')
{
int cnt=0;
while(s[i+1]=='O'&&s[i+2]=='I')
{
i+=2, cnt++;
if(s[i]=='I'&&cnt==n)
{
cnt--, ans++;
}
}
}
}
cout<<ans<<endl;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/5525/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.