1291 | 2022-03-30 14:08:19 | k_balint | Nemzetközi Rántott Hús Fesztivál | cpp14 | Wrong answer 23/100 | 120ms | 31180 KiB |
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int suf[1000006];
int best[1000006];
stack<int> st;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>s;
for(int i=n-1;i>=0;i--){
if(s[i]=='H'){
best[i]=i;
st.push(i);
}
else{
if(!st.empty()) st.pop();
best[i]=st.empty()?n:st.top();
}
}
for(int i=n-1;i>=0;i--){
suf[i]=suf[i+1]+(s[i]=='K');
}
for(int i=0;i<n;i++){
if(best[i] != n){
cout << (best[i]-i)/2 << ' ';
}
else{
cout << min((n-i)/2,n-i-suf[i]) << ' ';
}
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 2ms | 1820 KiB | ||||
2 | Wrong answer | 2ms | 1984 KiB | ||||
subtask2 | 0/7 | ||||||
3 | Wrong answer | 1ms | 1872 KiB | ||||
4 | Accepted | 1ms | 1876 KiB | ||||
subtask3 | 9/9 | ||||||
5 | Accepted | 2ms | 1936 KiB | ||||
6 | Accepted | 2ms | 1952 KiB | ||||
7 | Accepted | 2ms | 1956 KiB | ||||
subtask4 | 14/14 | ||||||
8 | Accepted | 101ms | 20660 KiB | ||||
9 | Accepted | 103ms | 21636 KiB | ||||
10 | Accepted | 105ms | 22636 KiB | ||||
11 | Accepted | 103ms | 23672 KiB | ||||
12 | Accepted | 100ms | 24644 KiB | ||||
13 | Accepted | 112ms | 25632 KiB | ||||
14 | Accepted | 100ms | 26612 KiB | ||||
15 | Accepted | 93ms | 27552 KiB | ||||
subtask5 | 0/11 | ||||||
16 | Wrong answer | 1ms | 8008 KiB | ||||
17 | Accepted | 1ms | 8020 KiB | ||||
18 | Accepted | 1ms | 8020 KiB | ||||
subtask6 | 0/29 | ||||||
19 | Wrong answer | 2ms | 8068 KiB | ||||
20 | Accepted | 2ms | 8080 KiB | ||||
21 | Accepted | 2ms | 8164 KiB | ||||
22 | Accepted | 2ms | 8092 KiB | ||||
subtask7 | 0/30 | ||||||
23 | Wrong answer | 104ms | 26788 KiB | ||||
24 | Accepted | 120ms | 27824 KiB | ||||
25 | Accepted | 108ms | 26768 KiB | ||||
26 | Wrong answer | 111ms | 27708 KiB | ||||
27 | Accepted | 104ms | 28704 KiB | ||||
28 | Accepted | 109ms | 27712 KiB | ||||
29 | Accepted | 104ms | 28648 KiB | ||||
30 | Wrong answer | 104ms | 29628 KiB | ||||
31 | Wrong answer | 104ms | 28392 KiB | ||||
32 | Accepted | 107ms | 27468 KiB | ||||
33 | Accepted | 109ms | 28444 KiB | ||||
34 | Accepted | 104ms | 28444 KiB | ||||
35 | Accepted | 109ms | 28408 KiB | ||||
36 | Accepted | 94ms | 29384 KiB | ||||
37 | Accepted | 96ms | 28196 KiB | ||||
38 | Accepted | 98ms | 29176 KiB | ||||
39 | Accepted | 96ms | 30164 KiB | ||||
40 | Accepted | 97ms | 31180 KiB |