QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#339426#8049. Equal SumsxlwangWA 984ms8744kbC++142.4kb2024-02-27 11:45:132024-02-27 11:45:13

Judging History

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

  • [2024-02-27 11:45:13]
  • 评测
  • 测评结果:WA
  • 用时:984ms
  • 内存:8744kb
  • [2024-02-27 11:45:13]
  • 提交

answer

#include<bits/stdc++.h>
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define randfind(l,r) (rnd()%((r)-(l)+1)+(l))
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
using namespace std;
inline int read(){
	int x=0;
	bool f=0;
	char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
inline void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
//inline void init(){
//	int t=read();
//	while(t--) work();
//}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int Maxn=5e2+10,N=500,mod=998244353;
int f[2][Maxn][Maxn<<1];
int l1[Maxn],r1[Maxn],l2[Maxn],r2[Maxn];
int n,m;
inline void init(){
    n=read();m=read();
    fr(i,1,n) l1[i]=read(),r1[i]=read();
    fr(i,1,m) l2[i]=read(),r2[i]=read();
}
inline void add(int &x,int y){
    x+=y;if(x>=mod) x-=mod;
}
int ans[Maxn][Maxn];
inline void work(){
    f[0][0][N]=1;
    fr(tp,0,n+m-1){
        fr(i,0,min(n,tp)){
            int _i=tp-i;
            fr(j,0,2*N){
                if(!f[tp&1][i][j]) continue;
                // cout<<tp<<' '<<i<<' '<<j<<endl;
                if(j<=N && i<n){
                    add(f[tp&1^1][i+1][j+l1[i+1]],f[tp&1][i][j]);
                    add(f[tp&1^1][i+1][j+r1[i+1]+1],mod-f[tp&1][i][j]);
                }
                else if(_i<m){
                    add(f[tp&1^1][i][j-r2[_i+1]],f[tp&1][i][j]);
                    add(f[tp&1^1][i][j-l2[_i+1]+1],mod-f[tp&1][i][j]);
                }
            }
        }
        fr(i,0,min(n,tp+1)) fr(j,0,2*N){
            add(f[tp&1^1][i][j],f[tp&1^1][i][j-1]);
        }
        // fr(i,0,min(n,tp+1)) fr(j,0,2*N) if(f[tp&1^1][i][j]) cout<<tp<<' '<<i<<' '<<j<<' '<<f[tp&1^1][i][j]<<endl;
        fr(i,0,min(n,tp+1)) add(ans[i][tp+1-i],f[tp&1^1][i][N]);
        fr(i,0,min(n,tp)) fr(j,0,2*N) f[tp&1][i][j]=0;
    }
    fr(i,1,n){
        fr(j,1,m) writepl(ans[i][j]);
        puts("");
    }
}
signed main(){
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
    init();work();
    // printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3644kb

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
Wrong Answer
time: 984ms
memory: 8744kb

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:

411 79401 9145270 673005095 180581065 984223118 586589234 293043270 404363796 865361724 665487988 118838806 926189944 226338288 521479857 808644951 786041288 340769021 177100 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

wrong answer 249030th numbers differ - expected: '269441650', found: '409042652'