-
-
Save honux77/00f2f152d471de15b069723d7facc112 to your computer and use it in GitHub Desktop.
BOJ 5525 IOI x n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
using ull = long long int; | |
int main() | |
{ | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int n, m; | |
cin >> n >> m; | |
string s; | |
cin >> s; | |
int ans = 0; | |
for(int i = 0; i < s.size() - (2 * n + 1); i++) { | |
if (s[i] == 'I') { | |
int p = 0; | |
while (s[i + 1] == 'O' && s[i + 2] == 'I') { | |
p++; | |
i+=2; | |
} | |
if (p >= n) { | |
ans += p - n + 1; | |
} | |
} | |
} | |
cout << ans << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment