Submission #906209

# Submission time Handle Problem Language Result Execution time Memory
906209 2024-01-13T16:13:41 Z vjudge1 JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n, k, dem = 0;

map <char, ll> cnt;

char a[5] = {'J', 'O', 'I'};

string s;

int main(){

	ios_base::sync_with_stdio(0);
	
	cin.tie(0);
	
	cin>>n>>k>>s;
	
	ll i = 0, j = 0;
	
	n--;
	
	bool flag = false;
	
	while(i <= n){
		
		if(flag == false){
			
			while(s[i] != 'J' && i <= n){
				
				i++;
			}
			while(s[n] != 'I' && n > 0){
				
				n--;
			}
			flag = true;
		}
		else{
			
			while(cnt[a[j]] < k && i <= n){
				
				if(s[i] == a[j]) cnt[s[i]]++;
				
				else dem++;
				
				i++;
			}
			j++;
		}
//		cout<<cnt['J']<<" "<<cnt['O']<<" "<<cnt['I']<<'\n';
	}
	if(cnt['J'] == cnt['O'] && cnt['O'] == cnt['I'] && cnt['J'] == k) cout<<dem;
	
	else cout<<-1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -