-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1722D.cpp
More file actions
41 lines (36 loc) · 816 Bytes
/
1722D.cpp
File metadata and controls
41 lines (36 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--){
ll n,ans=0;
string s;
cin>>n>>s;
vector<ll>current(n), change(n);
for(int i=0;i<n;i++){
if(s[i]=='R'){
current[i]=n-i+1;
change[i]=i-n+i-1;
}
else{
current[i]=i;
change[i]=n-i-i+1;
}
ans+=current[i];
}
sort(change.begin(),change.end());
reverse(change.begin(),change.end());
ll res=0;
for(int k=1;k<=n;k++){
if(change[k-1]>0){
res=res+change[k];
}
cout<<res<<" ";
}
cout<<"\n";
}
return 0;
}