100452024-03-25 18:58:07111Nemzetközi Rántott Hús Fesztiválcpp17Time limit exceeded 56/100583ms30452 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	string S;
	cin>>S;
	for(int i=0;i<N;i++){
		int a=0;
		int c=0;
		int d=0;
		for(int j=i;j<N;j++){
			char C=S[j];
			if(C=='H'){
				if(c==0){
					if(d==0){
						break;
					}
					else{
						c++;
						d--;
					}
				}
				else{
					c--;
					a++;
				}
			}
			if(C=='K'){
				c++;
			}
			if(C=='M'){
				if(c==0){
					c++;
				}
				else{
					a++;
					c--;
					d++;
				}
			}
		}
		cout<<a<<' ';
	}
	cout<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1976 KiB
2Accepted46ms2324 KiB
subtask27/7
3Accepted3ms2440 KiB
4Accepted3ms2604 KiB
subtask39/9
5Accepted7ms2908 KiB
6Accepted3ms3152 KiB
7Accepted28ms3268 KiB
subtask40/14
8Time limit exceeded564ms4840 KiB
9Time limit exceeded555ms5924 KiB
10Time limit exceeded556ms7136 KiB
11Time limit exceeded559ms7996 KiB
12Time limit exceeded550ms9124 KiB
13Time limit exceeded555ms10204 KiB
14Time limit exceeded565ms11520 KiB
15Time limit exceeded552ms12516 KiB
subtask511/11
16Accepted3ms12256 KiB
17Accepted3ms12228 KiB
18Accepted3ms12260 KiB
subtask629/29
19Accepted52ms12284 KiB
20Accepted48ms12296 KiB
21Accepted27ms12296 KiB
22Accepted24ms12204 KiB
subtask70/30
23Time limit exceeded550ms13544 KiB
24Time limit exceeded546ms14528 KiB
25Time limit exceeded569ms15500 KiB
26Time limit exceeded572ms16568 KiB
27Time limit exceeded554ms17640 KiB
28Time limit exceeded573ms18536 KiB
29Time limit exceeded552ms19484 KiB
30Time limit exceeded578ms20492 KiB
31Time limit exceeded572ms21368 KiB
32Time limit exceeded556ms22500 KiB
33Time limit exceeded579ms23684 KiB
34Time limit exceeded583ms24796 KiB
35Time limit exceeded563ms25736 KiB
36Time limit exceeded573ms26836 KiB
37Time limit exceeded574ms27620 KiB
38Time limit exceeded546ms28536 KiB
39Time limit exceeded580ms29544 KiB
40Time limit exceeded551ms30452 KiB