#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define all(x) x.begin(), x.end()
#define vi vector<int>
//posu[3] = 5 means 3rd U 5th position pe
//pred[4] = 7 means 4....n-1 tak 7 D hai
//nowu[4] = 10 means 0 to 4 tak 10 U hai
int n;
int AT;
vi posd[2], posu[2], pred[2], nowu[2], lastd[2], disd[2], disu[2];
void build(string &s, vi &posd, vi &posu, vi &pred, vi &nowu, vi &lastd){
int i, n = s.size();
int cntd = 0, cntu = 0;
pred[n] = 0;
Fo(i, n-1, -1) pred[i] = pred[i+1]+(s[i]=='D');
nowu[0] = s[0] == 'U';
Fo(i, 1, n) nowu[i] = nowu[i-1]+(s[i]=='U');
fo(i, n){
if(s[i]=='U'){
++cntu;
posu[cntu] = i;
}
}
Fo(i, n-1, -1){
if(s[i]=='D'){
++cntd;
posd[cntd] = i;
}
}
lastd[0] = -1;
fo(i, n) {
if(s[i]=='D'){
lastd[i]=i, disd[AT][i] = i;
}
else if(i) lastd[i] = lastd[i-1];
if(i) disd[AT][i] += disd[AT][i-1];
}
disu[AT][n] = 0;
Fo(i, n-1, -1){
if(s[i]=='U'){
++cntd;
posd[cntd] = i;
disu[AT][i] = n-i;
}
disu[AT][i] += disu[AT][i+1];
}
}
ll f(int x, int y, int cnt){
//x>y
if(x<=y)return 0;
cnt--;
ll ans = disd[AT][x]-disd[AT][y]-cnt*y;
return ans;
}
ll g(int x, int y, int cnt){
//x>y
if(x<=y)return 0;
cnt--;
ll ans = disu[AT][y]-disu[AT][x]-cnt*(n-x);
return ans;
}
ll query(int x1, vi &posd, vi &posu, vi &pred, vi &nowu, vi &lastd){
ll ans = 0;
int x2 = lastd[x1];
// cout<<x1<<" "<<x2<<endl;
int x = nowu[x2], y = pred[x1];
int r1 = posd[y], r2 = posd[1];
int l1 = posu[x], l2 = posu[1];
if (l2>x2) l2 = -1;
if (l1>x2) l1 = -1;
if(r2<x1) r2 = -1;
if(r1<x1) r1 = -1;
ll base1 = r1-x1, base2 = x2-l1;
int nou = x1-x2-1;
if(x2==-1)x = 0;
int cut = max(0, nou);
// cout<<nou<<" ."<<cut<<endl;
// cout<<l2<<" "<<l1<<" "<<x2<<" "<<x1<<" "<<r1<<" "<<r2<<endl;
// cout<<x<<" "<<y<<" "<<base1<<endl;
if (nou >= y){
ans = y + n-(x1-y) + 2*y*base1 + 2*f(r2,r1,y);
return ans;
}
int r2_ = r1;
if(cut){
y -= cut;
r2_ = posd[y+1];
// cout<<base1<<" "<<y<<" "<<r2_<<" "<<r1<<endl;
ans = 2*cut*(base1) +cut+ 2*f(r2_, r1, y);
r2_ = posd[y];
// cout<<r2_<<" "<<r1<<endl;
base1 = r2_-x2-1;
}
// cout<<ans<<" "<<base1<<endl;
// cout<<x<<" "<<y<<endl;
if(x2==-1){
return ans+1 + 2*(base1);
}
ll steps1 = x+1, steps2 = x;
int l2_ = l2, r3 = posd[y-x];
if (x<y){
// cout<<base1<<" "<<base2<<endl;
// cout<<x<<" "<<y<<endl;
// cout<<r2_<<" "<<r3<<endl;
ans += x2+1;
ans += 2*steps1*(base1) + steps1 + 2*f(r3,r2_, x+1);
ans += 2*steps2*(base2) + steps2 + 2*g(l1,l2_,x);
return ans;
}
if (x==y){
steps1 = steps2 = x; r3 = r2, l2_ = l2;
// cout<<l2_<<" "<<l1<<" "<<r2_<<" "<<r3<<endl;
ans += n-x2-1;
// cout<<'s'<<" "<<x1<<endl;
ans += 2*steps1*(base1) + steps1 + 2*f(r3,r2_,y);
ans += 2*steps2*(base2) + steps2 + 2*g(l1,l2_,x);
return ans;
}
if (x>y){
steps1 = steps2 = y; r3 = r2, l2_ = posu[x-y+1];
ans += n-x2-1;
ans += 2*steps1*(base1) + steps1 + 2*f(r3,r2_, y);
ans += 2*steps2*(base2) + steps2 + 2*g(l1,l2_,y);
return ans;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int i,k,j;
string s;
cin>>n;
cin>>s;
string ss = s;
fo(i, n) ss[i] = s[i]=='U'?'D':'U';
reverse(all(ss));
// cout<<s<<" "<<ss<<endl;
fo(i, 2){
lastd[i].resize(n+2, -1);
disd[i].resize(n+2, 0);
disu[i].resize(n+2, 0);
pred[i].resize(n+2, -1);
nowu[i].resize(n+2, -1);
posd[i].resize(n+2, -1);
posu[i].resize(n+2, -1);
}
AT = 0;
build(s,posd[0], posu[0], pred[0], nowu[0], lastd[0]);
AT = 1;
build(ss,posd[1], posu[1], pred[1], nowu[1], lastd[1]);
// fo(i, n) cout<<disu[0][i]<<" ";
// cout<<endl;
// fo(i, n) cout<<pred[0][i]<<" ";
// cout<<endl;
int at = 0;
Fo(i, 0, n){
at = (s[i]=='D') ;
int ni = i;
AT = at;
if(at) ni = n-i-1;
cout<<query(ni, posd[at], posu[at], pred[at], nowu[at], lastd[at])<<" ";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZ2MgZ2V0Y2hhcl91bmxvY2tlZAojZGVmaW5lIGZvKGksbikgZm9yKGk9MDtpPG47aSsrKQojZGVmaW5lIEZvKGksayxuKSBmb3IoaT1rO2s8bj9pPG46aT5uO2s8bj9pKz0xOmktPTEpCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgYWxsKHgpIHguYmVnaW4oKSwgeC5lbmQoKQojZGVmaW5lIHZpIHZlY3RvcjxpbnQ+Ci8vcG9zdVszXSA9IDUgbWVhbnMgM3JkIFUgNXRoIHBvc2l0aW9uIHBlCi8vcHJlZFs0XSA9IDcgbWVhbnMgNC4uLi5uLTEgdGFrIDcgRCBoYWkKLy9ub3d1WzRdID0gMTAgbWVhbnMgMCB0byA0IHRhayAxMCBVIGhhaQppbnQgbjsKaW50IEFUOwp2aSBwb3NkWzJdLCBwb3N1WzJdLCBwcmVkWzJdLCBub3d1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