QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#189501#6132. Repair the Artwork275307894aWA 3ms5612kbC++141.2kb2023-09-27 16:05:132023-09-27 16:05:32

Judging History

你现在查看的是最新测评结果

  • [2023-09-27 16:05:32]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5612kb
  • [2023-09-27 16:05:13]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=100+5,M=N*20+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
int n,m,A[N];ll dp[N][N*N/2];
ll mpow(ll x,int y=mod-2){ll ans=1;while(y) y&1&&(ans=ans*x%mod),y>>=1,x=x*x%mod;return ans;}
void Solve(){
	int i,j,h;scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++) scanf("%d",&A[i]);
	A[0]=A[n+1]=1;for(i=0;i<=n+1;i++) Me(dp[i],0);dp[0][0]=1;
	for(i=1;i<=n+1;i++) {
		if(!A[i]) continue;
		for(j=i-1;~j;j--) {
			for(h=0;h<=j*(j-1)/2;h++) if(dp[j][h]) dp[i][h+(i-j-1)*(i-j)/2]+=dp[j][h]*(A[i]^1?-1:1);
			if(A[j]==1) break;
		}
	}
	ll ans=0;for(i=0;i<=n*(n+1)/2;i++) ans+=dp[n+1][i]*mpow(i,m);
	printf("%lld\n",(ans%mod+mod)%mod);
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4140kb

input:

3
2 2
2 0
3 2
2 1 0
3 1
2 1 0

output:

8
3
1

result:

ok 3 number(s): "8 3 1"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 5612kb

input:

100
2 1
0 1
2 1
2 1
2 1
1 1
1 6
2
1 14
2
3 12
2 2 2
6 13
2 2 0 2 0 2
7 14
0 0 0 0 2 2 0
5 8
2 2 0 0 0
5 5
2 2 0 0 0
12 3
0 2 0 2 2 0 1 2 2 2 2 0
7 11
2 2 0 1 0 1 0
4 4
2 1 2 2
7 5
1 1 0 0 1 0 0
2 14
2 1
15 17
2 2 1 2 0 0 0 0 2 0 1 0 0 0 0
15 11
1 1 2 0 1 2 0 0 1 0 2 1 1 1 1
15 18
1 0 1 0 2 2 1 2 0 1...

output:

1
1
0
1
1
179226655
469101477
888829612
462316734
650344
2208
551134486
146
7776
1
533745508
44785707
838292321
937486125
240123632
151030497
931324055
203109971
423118886
295259581
8676476
678784069
294354547
651938580
461683393
726098121
73856090
911449951
908848170
461463496
629288437
100251338
4...

result:

wrong answer 6th numbers differ - expected: '175715347', found: '179226655'