QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#453531#8049. Equal Sumsucup-team3282WA 1ms3720kbC++141.6kb2024-06-23 23:08:062024-06-23 23:08:07

Judging History

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

  • [2024-06-23 23:08:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-06-23 23:08:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=510;
const int mod=998244353;
const int maxv=500;

int n,m;
int la[maxn],ra[maxn],lb[maxn],rb[maxn];
int f[2][maxn][maxv*2+10],s[2][maxn][maxv*2+10];

int pls(int x,int y){
	return x+y<mod?x+y:x+y-mod;
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>la[i]>>ra[i];
	for(int j=1;j<=m;j++)
		cin>>lb[j]>>rb[j];
	
	for(int k=-maxv;k<=maxv;k++){
		if(la[1]<=k&&k<=ra[1])
			f[1][0][k+maxv+1]=1;
		s[1][0][k+maxv+1]=pls(s[1][0][k-1+maxv+1],f[1][0][k+maxv+1]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
//			cout<<"---------------------"<<i<<' '<<j<<"---------------------"<<endl;
			for(int k=-maxv;k<=maxv;k++){
				f[i&1][j][k]=s[i&1][j][k]=0;
				if(k<=ra[i] && k-max(k,la[i])>=-maxv){
//					cout<<'\t'<<max(k-ra[i],-maxv)<<"~"<<k-max(k,la[i])<<" -> "<<k<<endl;
					f[i&1][j][k+maxv+1]=pls(pls(mod-s[i&1^1][j][max(k-ra[i],-maxv)-1 +maxv+1],
					                        s[i&1^1][j][k-max(k,la[i])+maxv+1]),f[i&1][j][k+maxv+1]);
				}
				if(-k+1<=rb[j] && k+max(-k+1,lb[j])<=maxv){
//					cout<<'\t'<<k+max(-k+1,lb[j])<<"~"<<min(k+rb[j],maxv)<<" -> "<<k<<endl;
					f[i&1][j][k+maxv+1]=pls(pls(mod-s[i&1][j-1][k+max(-k+1,lb[j])-1 +maxv+1],
					                        s[i&1][j-1][min(k+rb[j],maxv) +maxv+1]),f[i&1][j][k+maxv+1]);
				}
//				cout<<"f "<<i<<' '<<j<<' '<<k<<' '<<f[i&1][j][k+maxv+1]<<endl;
				s[i&1][j][k+maxv+1]=pls(s[i&1][j][k-1+maxv+1],f[i&1][j][k+maxv+1]);
			}
			cout<<f[i&1][j][maxv+1]<<' ';
		}
		cout<<endl;
	}
	
	
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3720kb

input:

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

output:

2 0 998244351 
0 7 9 

result:

wrong answer 3rd numbers differ - expected: '0', found: '998244351'