# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
212521 | 2020-03-23T11:32:18 Z | DystoriaX | JJOOII 2 (JOI20_ho_t2) | C++14 | 5 ms | 256 KB |
#include <bits/stdc++.h> using namespace std; int n, k; char s[200010]; vector<int> J, O, I; int lf[200010]; int ans = 1e9; int main(){ scanf("%d%d", &n, &k); scanf(" %s", s + 1); for(int i = 1; i <= n; i++){ if(s[i] == 'J') J.emplace_back(i); if(s[i] == 'O') O.emplace_back(i); if(s[i] == 'I') I.emplace_back(i); } for(int i = k - 1; i < (int) J.size(); i++){ lf[J[i]] = J[i - k + 1]; } for(int i = k - 1; i < (int) O.size(); i++){ auto it = lower_bound(J.begin(), J.end(), O[i - k + 1] - 1); if(it == J.end() || lf[*it] == 0 || *it > O[i]) continue; lf[O[i]] = lf[*it]; } for(int i = k - 1; i < (int) I.size(); i++){ auto it = lower_bound(O.begin(), O.end(), I[i - k + 1] - 1); if(it == O.end() || lf[*it] == 0 || *it > I[i]) continue; ans = min(ans, I[i] - lf[*it] + 1 - 3 * k); } if(ans == 1e9) ans = -1; printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Incorrect | 4 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Incorrect | 4 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Incorrect | 4 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |