Skip to content

Instantly share code, notes, and snippets.

@honux77
Created November 4, 2020 11:24
Show Gist options
  • Save honux77/00f2f152d471de15b069723d7facc112 to your computer and use it in GitHub Desktop.
Save honux77/00f2f152d471de15b069723d7facc112 to your computer and use it in GitHub Desktop.
BOJ 5525 IOI x n
#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