| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1341835 | cansu_mutlu | JJOOII 2 (JOI20_ho_t2) | C++20 | 2094 ms | 752 KiB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
cin >> n >> k;
string a,s;
cin >> s;
int ans = 1e18;
for(int r = n-1;r>=0;r--)
{
char cur = 'I';
int l = r;
int ok = 0;
int cnt = 0;
queue<int> j,o,i;
for(;l>=0;l--)
{
if(s[l]==cur)
{
cnt++;
if(cnt==k)
{
if(cur=='J')
{
ok = 1;
break;
}
else if(cur=='O') cur = 'J';
else cur = 'O';
cnt = 0;
}
}
}
if(ok) ans = min(ans,r-l+1);
}
if(ans==1e18) cout << -1 << endl;
else cout << ans-(3*k) << endl;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
