QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626672#8049. Equal SumsEternatisRE 1ms3916kbC++171.7kb2024-10-10 11:36:532024-10-10 11:36:58

Judging History

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

  • [2024-10-10 11:36:58]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3916kb
  • [2024-10-10 11:36:53]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define N 501
#define i128 __int128
#define db long double
#define pii pair<int,int>
#define st first
#define ed second
#define mkp make_pair
#define pb push_back
#define eps 1e-9
#define mod 998244353
#define mod2 1000000007
#define bs 13131
#define bs2 131
#define INF 0x3f3f3f3f3f3f3f3f
#define il inline
#define vi vector<int>
#define ins insert
#define umap unordered_map
#define uset unordered_set
#define R(x) x.begin(),x.end()
#define B(x) x.begin()
#define E(x) x.end()
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
il int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int T=1,n,m,q,k;
int s[N];
int l[2][N],r[2][N];
int f[N][N][N<<1];
signed main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++)l[0][i]=read(),r[0][i]=read();
	for(int i=1;i<=m;i++)l[1][i]=read(),r[1][i]=read();
	int M=500;
	f[0][0][M]=1,f[0][0][M+1]=-1;
	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
		for(int k=1;k<=M<<1;k++)f[i][j][k]=(f[i][j][k]+f[i][j][k-1])%mod;
		for(int k=0;k<M;k++)f[i+1][j][k+l[0][i+1]]=(f[i+1][j][k+l[0][i+1]]+f[i][j][k])%mod,f[i+1][j][k+r[0][i+1]+1]=(f[i+1][j][k+r[0][i+1]+1]-f[i][j][k])%mod;
		for(int k=M;k<=M<<1;k++)f[i][j+1][k-r[1][j+1]]=(f[i][j+1][k-r[1][j+1]]+f[i][j][k])%mod,f[i][j+1][k-l[1][j+1]+1]=(f[i][j+1][k-l[1][j+1]+1]-f[i][j][k])%mod;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			printf("%lld ",(f[i][j][M]+mod)%mod);
		puts("");
	}
	return 0;
}


详细

Test #1:

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

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
Runtime Error

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: