QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#724281 | #9128. Priority Queue 3 | 11d10xy | WA | 150ms | 6964kb | C++14 | 1.4kb | 2024-11-08 11:39:46 | 2024-11-08 11:39:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
constexpr i64 mod=998244353;
inline i64 qpow(i64 p,i64 t){
i64 r=1;for(;t;t>>=1,p=p*p%mod)if(t&1)(r*=p)%=mod;
return r;
}
int n,m,a[310];
char str[310];
i64 f[310][310][2],fac[310],ifac[310];
int main(){
scanf("%d%d%s",&n,&m,str+1);
for(int i=1;i<=m;i++)scanf("%d",&a[i]);
fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
ifac[n]=qpow(fac[n],mod-2);for(int i=n;i>=1;i--)ifac[i-1]=ifac[i]*i%mod;
f[m][0][0]=1;
for(int i=1,c1=0,c2=0;i<=n+m;i++){
i64 g[310][310][2]{};
if(str[i]=='+'){
for(int j=0;j<=m;j++){
for(int k=0;k<=m;k++){
for(int o:{0,1}){
(g[j][k][o]+=f[j][k][o]*(n-a[j]-c1+c2-m+j+k))%=mod;
}
(g[j][k+1][1]+=f[j][k][0])%=mod;
(g[j][k+1][0]+=f[j][k][0])%=mod;
(g[j][k+1][1]+=f[j][k][1])%=mod;
}
}
c1++;
}else{
for(int j=0;j<=m;j++){
for(int k=1;k<=m;k++){
(g[j][k-1][0]+=f[j][k][0])%=mod;
if(k>1)(g[j][k-1][1]+=f[j][k][1])%=mod;
}
for(int x=0;x<j;x++){
int v=c2-m+j,w=j-x-1;
if(w<=v)(g[x][0][0]+=f[j][1][1]*fac[v]%mod*ifac[v-w])%=mod;
}
}
c2++;
}
memcpy(f,g,sizeof(g));
}
printf("%lld",f[0][0][0]);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 6956kb
input:
4 2 ++-++- 1 3
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 3ms
memory: 6892kb
input:
6 4 ++-++---++ 2 3 4 6
output:
48
result:
ok "48"
Test #3:
score: 0
Accepted
time: 6ms
memory: 6964kb
input:
20 10 ++++-++++++--+--+-+++++--+-++- 1 2 3 4 5 6 7 9 12 13
output:
179396825
result:
ok "179396825"
Test #4:
score: 0
Accepted
time: 3ms
memory: 6956kb
input:
8 5 +-+++-++++--- 1 2 3 4 8
output:
4896
result:
ok "4896"
Test #5:
score: 0
Accepted
time: 2ms
memory: 6828kb
input:
4 3 +++-+-- 1 2 3
output:
24
result:
ok "24"
Test #6:
score: 0
Accepted
time: 0ms
memory: 6852kb
input:
7 3 ++++-+++-- 1 2 3
output:
4896
result:
ok "4896"
Test #7:
score: 0
Accepted
time: 3ms
memory: 6848kb
input:
9 1 +++++++++- 1
output:
362880
result:
ok "362880"
Test #8:
score: 0
Accepted
time: 0ms
memory: 6776kb
input:
5 1 +++++- 1
output:
120
result:
ok "120"
Test #9:
score: 0
Accepted
time: 0ms
memory: 6832kb
input:
8 4 +-++-++++--+ 1 2 3 4
output:
9216
result:
ok "9216"
Test #10:
score: 0
Accepted
time: 2ms
memory: 6892kb
input:
4 2 +-++-+ 1 4
output:
4
result:
ok "4"
Test #11:
score: 0
Accepted
time: 2ms
memory: 6852kb
input:
4 2 +-++-+ 1 3
output:
6
result:
ok "6"
Test #12:
score: 0
Accepted
time: 3ms
memory: 6900kb
input:
6 3 +++--++-+ 2 3 5
output:
24
result:
ok "24"
Test #13:
score: 0
Accepted
time: 2ms
memory: 6900kb
input:
4 2 +-++-+ 2 3
output:
4
result:
ok "4"
Test #14:
score: 0
Accepted
time: 56ms
memory: 6828kb
input:
240 66 ++-++++-++++++++-+++++++-+-+++++++++-+-+++++-++-+-++-----+-++++--+--+-+-+++++++---+++++++++-+--+++++-+-++-++++++++-+-+++++++++++-++++++++-+--+++-++++-+++++-+++++-++++++++++++-+-++++-+++--++++++-++++-+++++++++++++++++++++-+-++++++++-+-++++-++++++++++++-+-+-++++--+++--+++-++++++--++++++++++++++...
output:
453300017
result:
ok "453300017"
Test #15:
score: -100
Wrong Answer
time: 150ms
memory: 6784kb
input:
281 202 +-+++---++--+-+++++-+++----+--++-+++--++++-++-+++--++++-+-+++++++++-+-------++++---+++-+-++++-++-+++-++--+--++++++-+++-+-+++++--++++-----+-+++-++--+-++++++-++-+++++--+--+-----++-+-+--+++++++-+-++++-+-+-+++----++--++-+++++++-+++-+---+--+-+-++--++-++--+--+++-+++++++++--++++---+-++++++++-+-++--...
output:
0
result:
wrong answer 1st words differ - expected: '917532569', found: '0'