# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
583930 |
2022-06-26T13:53:47 Z |
forelax |
JJOOII 2 (JOI20_ho_t2) |
C++14 |
|
1 ms |
212 KB |
#include<bits/stdc++.h>
using namespace std;
int main() {
string s;
int K;
cin >> s >> K;
int n = s.length();
int rez = n;
int j, k, l, cj = 0, co = 0, ci = 0;
for (j = 0;j < n && cj < K;j++) {
if (s[j] == 'J')cj++;
}
if (cj != K) {
cout << -1;
return 0;
}
for (k = j;k < n && co < K;k++) {
if (s[k] == 'O')co++;
}
if (co != K) {
cout << -1;
return 0;
}
for (l = k;l < n && ci < K;l++) {
if (s[l] == 'I')ci++;
}
if (ci != K) {
cout << -1;
return 0;
}
for (int i = 0; i < n; i++) {
if (s[i] == 'J') {
cj--;
for (;j < n && cj < K;j++) {
if (s[j] == 'J')cj++;
if (s[j] == 'O')
for (;k < n && co < K;k++) {
if (s[k] == 'O')co++;
if (s[k] == 'I')
for (;l < n && ci < K;l++) {
if (s[l] == 'I')ci++;
}
}
}
}
if (cj == K && co == K && ci == K) {
rez = min(rez, l - i + 1 - 3 * K);
}
}
cout << rez;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |