#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
re int t=0;re char v=getchar();
while(v<'0')v=getchar();
while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
return t;
}
const int M=998244353;
inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
inline int Mod(re int x){return x>=M?x-M:x;}
inline int ksm(re int x,re int y){
re int s=1;
while(y){
if(y&1)s=1ll*s*x%M;
x=1ll*x*x%M,y>>=1;
}
return s;
}
int t,n,m,a[1000002],ans,A,B,R[1000002],stk[1000002],tp,sum,f[6002][6002][2],g[6002][6002][2];
char s[1000002];
signed main(){
n=read();
scanf("%s",s+1);
f[1][0][0]=1;
for(re int i=1;i<=n+n;++i){
if(s[i]!='+'){
for(re int j=0;j<=i;++j)
for(re int o=0;o<2;++o){
re int nj,no,typ;
if(o==0||j==0){
nj=j+1,no=0,typ=M-i;
}
else{
nj=j-1,no=(j==1)?0:1,typ=i;
}
add(f[i+1][nj][no],f[i][j][o]);
add(g[i+1][nj][no],g[i][j][o]);
add(g[i+1][nj][no],1ll*f[i][j][o]*typ%M);
}
}
if(s[i]!='-'){
for(re int j=0;j<=i;++j)
for(re int o=0;o<2;++o){
re int nj,no,typ;
if(o==1||j==0){
nj=j+1,no=1,typ=M-i;
}
else{
nj=j-1,no=0,typ=i;
}
add(f[i+1][nj][no],f[i][j][o]);
add(g[i+1][nj][no],g[i][j][o]);
add(g[i+1][nj][no],1ll*f[i][j][o]*typ%M);
}
}
}
printf("%d",g[n+n+1][0][0]);
}
./Main.cpp: In function ‘long long int read()’:
./Main.cpp:6:9: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
6 | re int t=0;re char v=getchar();
| ^
./Main.cpp:6:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
6 | re int t=0;re char v=getchar();
| ^
./Main.cpp: At global scope:
./Main.cpp:12:25: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
12 | inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
| ^
./Main.cpp:12:34: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
12 | inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
| ^
./Main.cpp:13:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
13 | inline int Mod(re int x){return x>=M?x-M:x;}
| ^
./Main.cpp:14:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
14 | inline int ksm(re int x,re int y){
| ^
./Main.cpp:14:32: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
14 | inline int ksm(re int x,re int y){
| ^
./Main.cpp: In function ‘long long int ksm(long long int, long long int)’:
./Main.cpp:15:9: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
15 | re int s=1;
| ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:28:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
28 | for(re int i=1;i<=n+n;++i){
| ^
./Main.cpp:30:15: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
30 | for(re int j=0;j<=i;++j)
| ^
./Main.cpp:31:16: warning: ISO C++17 does not allow ‘register’ storage ...