QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#782729#8049. Equal SumshhironWA 2ms7832kbC++141.3kb2024-11-25 21:10:472024-11-25 21:10:47

Judging History

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

  • [2024-11-25 21:10:47]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7832kb
  • [2024-11-25 21:10:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read(){
	char ch=getchar();
	while(!isdigit(ch) && ch!='-') ch=getchar();
	int x=0,ff=1; if(ch=='-') ff=-1,ch=getchar();
	while(isdigit(ch)) x=(x<<3) + (x<<1) + (ch^48),ch=getchar();
	return x*ff;
}
const int N=505,P=998244353;
inline void add(int &x,int y){x+=y; x=x>=P?x-P:x;}
inline void sub(int &x,int y){x-=y; x=x<0?x+P:x;}
int n,m,f[2][N][N*2],F[N][N],la[N],ra[N],lb[N],rb[N];
int main(){
	n=read(); m=read();
	for(int i=1;i<=n;i++) la[i]=read(),ra[i]=read();
	for(int i=1;i<=m;i++) lb[i]=read(),rb[i]=read();
	int nw=0;  f[nw][0][500]=1; f[nw][0][501]=P-1;
	for(int i=0;i<=n;i++){
		memset(f[nw^1],0,sizeof(f[nw^1]));
		for(int j=0;j<=m;j++){
			for(int s=1;s<=1000;s++) add(f[nw][j][s],f[nw][j][s-1]);
			for(int s=0,bf;s<=1000;s++){
//				if(i&&!j) cout<<s<<" "<<f[nw][j][s]<<endl;
				if((bf=f[nw][j][s])){
				cout<<i<<" "<<j<<" "<<s<<endl;
				if(s==500) add(F[i][j],bf);
				if(s<=500 && i<n) add(f[nw^1][j][s+la[i+1]],bf),sub(f[nw^1][j][s+ra[i+1]+1],bf);
				if(s>500 && j<m) add(f[nw][j+1][s-rb[j+1]],bf),sub(f[nw][j+1][s-lb[j+1]+1],bf);
			}
			}
		}
		nw^=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) printf("%d ",F[i][j]);
		puts("");
	}
	return 0;
}//fff

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7832kb

input:

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

output:

0 0 500
1 0 501
1 0 502
1 1 497
1 1 498
1 1 499
1 1 500
1 1 501
1 2 499
2 1 499
2 1 500
2 1 501
2 1 502
2 1 503
2 2 499
2 2 500
2 2 501
2 2 502
2 3 498
2 3 499
2 3 500
2 3 501
2 0 0 
3 4 4 

result:

wrong answer 1st numbers differ - expected: '2', found: '0'