//#pragma GCC optimize("O3")
//#pragma GCC target ("avx2")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
const int N = 2e5 + 7;
int n, k, mn = 1e18;
string s;
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> k >> s;
s = '~' + s;
for (int i = 1; i <= n; i++) {
int J = 0, O = 0, I = 0, res = 0;
vector<int> aa;
for (int j = i + 1; j <= n; j++) {
if (s[j] == 'J') {
if (J == 2) {
res++;
aa.push_back(j);
continue;
}
J++;
}
if (s[j] == 'O') {
if (O == 2 || J < 2) {
res++;
aa.push_back(j);
continue;
}
O++;
}
if (s[j] == 'I') {
if (I == 2 || O < 2 || J < 2) {
res++;
aa.push_back(j);
continue;
}
I++;
}
}
int l = n, p = aa.size() - 1;
while (p >= 0 && aa[p] == l) {
l--;
p--;
res--;
}
if (J == 2 && O == 2 && I == 2) mn = min(mn, res);
}
cout << mn;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |