#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast")
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define MEM(x, n) memset(x, n, sizeof(x))
#define pii pair<int, int>
#define pdd pair<double, double>
#define DB(x) cerr << #x << " " << x << endl;
#define endl "\n"
#define Koying ios::sync_wit_stdio(0), cin.tie(0)
#define lowbit(x) x &(-x)
const int INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
#define MAXN 200005
int n, k;
string s;
void sol() {
cin >> n >> k;
cin >> s;
int mn = INF;
DB(s);
for (int i = 0; i <= n - k * 3; i++) {
int a, b, c;
a = b = c = 0;
for (int j = i; j < n; j++) {
if (a < k) {
a += (s[j] == 'J');
DB(a);
}
else if (b < k) {
b += s[j] == 'O';
}
else if (c < k) {
c += s[j] == 'I';
}
if (a == k && b == k && c == k) {
cmin(mn, j - i + 1);
break;
}
}
//cout << a << " " << b << " " << c << endl;
}
cout << mn - 3 * k << endl;
}
signed main()
{
Koying;
int t = 1;
//cin >> t;
sol();
return 0;
}
Compilation message
ho_t2.cpp: In function 'int main()':
ho_t2.cpp:13:21: error: 'sync_wit_stdio' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
13 | #define Koying ios::sync_wit_stdio(0), cin.tie(0)
| ^~~~~~~~~~~~~~
ho_t2.cpp:54:5: note: in expansion of macro 'Koying'
54 | Koying;
| ^~~~~~
ho_t2.cpp:55:9: warning: unused variable 't' [-Wunused-variable]
55 | int t = 1;
| ^