# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023731 | 2024-07-15T05:33:53 Z | vjudge1 | JJOOII 2 (JOI20_ho_t2) | C++17 | 1 ms | 600 KB |
#include <bits/stdc++.h> #include <algorithm> #include <iostream> #include <string> using namespace std; #define FOR(i,n) for(int i=0;i<n;i++) #define ROF(i,m,n) for(int i=m;i<=n;i++) #define vi vector<int> #define pb push_back #define alle(a) a.begin(),a.end() #define rall(n) rbegin(n),rend(n) #define int long long #define vecs vector<int> #define ll long long #define ss second #define ff first const int INF = 1e9 + 1; const int MOD = 1e9 + 7; const int N = 2005; void solve(){ int n, k; cin>>n>>k; string s; cin>>s; int a, b; int j1 = 0, o = 0, m = INF,y = 0; int i = 0, j = n - 1; while(i < n){ j1 = 0; o = 0; if(s[i] == 'J'){ while(j > i){ if(s[j] == 'I'){ int c = k; int i2 = i, j2 = j, o = 0; for(int f = i;f < j;f++){ if(s[f] == 'J'){ j1++; } if(j1 >= k){ i2 = f; break; } } int h = 0; for(int f = j;f >= i;f--){ if(s[f] == 'I'){ h = h + 1; } if(h == c){ j2 = f; break; } } if(j2 == j||i2 == i){ break; } o = 0; bool t = false; for(int f = i2;f <= j2;f++){ if(s[f] == 'O'){ o++; } if(o >= k){ t = true; break; } } if(t){ m = min((j - i + 1) - 3 * k,m); } } j--; } } i++; } if(m == INF){ cout<<"-1"; } else{ cout<<m; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; while (t--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |