QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#764424#8049. Equal SumsHollow_knight_TL 1ms5908kbC++141.2kb2024-11-20 09:04:402024-11-20 09:04:52

Judging History

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

  • [2024-11-20 09:04:52]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:5908kb
  • [2024-11-20 09:04:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=505;
inline ll read(){
	ll x=0;char f=1,c=getchar();
	while(c<48||c>57){if(c=='-')f=0;c=getchar();}
	while(c>=48&&c<=57){x=(x<<1)+(x<<3)+ll(c)-48;c=getchar();}
	return f==1?x:-x;
}
inline void upd(int&x,int y){if((x=x+y)>=mod)x=x-mod;}
struct Node{
	int n,l[N],r[N];
	int suml[N],sumr[N],dp[N][N*N];
	void sol(){
		dp[0][0]=1,suml[0]=sumr[0]=0;
		for(int i=1;i<=n;++i){
			l[i]=read(),r[i]=read();
			suml[i]=suml[i-1]+l[i],sumr[i]=sumr[i-1]+r[i];
			for(int j=l[i];j<=r[i];++j){
				for(int k=suml[i];k<=sumr[i];++k){
					upd(dp[i][k],dp[i-1][k-j]);
				}
			}
		}
	}
}x,y;
int solve(){
	x.n=read(),y.n=read();
	x.sol(),y.sol();
	for(int i=1;i<=x.n;++i){
		for(int j=1;j<=y.n;++j){
			ll res=0;
			for(int k=max(x.suml[i],y.suml[j]),mn=min(x.sumr[i],y.sumr[i]);k<=mn;++k){
				res=(res+1ll*x.dp[i][k]*y.dp[j][k]%mod)%mod;
			}
			printf("%lld ",res);
		}
		printf("\n");
	}
	return 0;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int T=1;
	while(T--){
		solve();
		if(T!=0)printf("\n");
	}
	fclose(stdin),fclose(stdout);
	return 0;
}

詳細信息

Test #1:

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

input:

2 3
1 2
2 3
1 4
2 2
1 3

output:

2 0 0 
3 4 4 

result:

ok 6 numbers

Test #2:

score: -100
Time Limit Exceeded

input:

500 500
19 458
1 480
7 485
50 461
12 476
15 461
48 466
40 453
46 467
9 458
27 478
26 472
46 459
29 490
6 500
17 487
48 484
28 472
28 459
25 480
4 491
29 481
36 460
2 491
44 499
22 473
20 458
4 483
27 471
2 496
11 461
43 450
2 478
37 466
15 459
42 482
7 451
19 455
2 453
47 475
48 450
1 474
46 471
9 4...

output:


result: