QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#765114 | #8049. Equal Sums | Ayaya | RE | 0ms | 5776kb | C++14 | 1.9kb | 2024-11-20 12:16:11 | 2024-11-20 12:16:12 |
Judging History
answer
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<array>
#include<unordered_map>
#include<vector>
#include<bitset>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<random>
#include<numeric>
using namespace std;
#define int long long
#define ll long long
#define ull unsigned long long
#define lc (x<<1)
#define rc (x<<1|1)
#define pii pair<int,int>
#define mkp make_pair
#define fi first
#define se second
const int Mx=305,B=300,p=998244353;
int read(){
char ch=getchar();
int Alice=0,Aya=1;
while(ch<'0'||ch>'9'){
if(ch=='-') Aya=-Aya;
ch=getchar();
}
while(ch>='0'&&ch<='9')
Alice=(Alice<<3)+(Alice<<1)+(ch^48),ch=getchar();
return (Aya==1?Alice:-Alice);
}
int n,m;
struct Seg{
int l,r;
}a[Mx],b[Mx];
int f[Mx][Mx<<1],g[Mx][Mx<<1];
int pf[Mx<<1],pg[Mx][Mx<<1];
signed main(){
n=read(),m=read();
for(int i=1;i<=n;i++) a[i].l=read(),a[i].r=read();
for(int i=1;i<=m;i++) b[i].l=read(),b[i].r=read();
pg[0][0+B]=1,pg[0][0+B+1]=p-1;
for(int i=0;i<=n;i++){
for(int j=0;j<=m;j++){
for(int s=-B+B;s<=B+B;s++){
f[j][s]=(s==0?pg[j][s]:pg[j][s]+f[j][s-1])%p;
pg[j][s]=0;
}
}
for(int j=0;j<=m;j++){
for(int s=-B+B;s<=B+B;s++){
pg[j][s]=0;
}
for(int s=-B+B;s<=0+B;s++){
int v=f[j][s];
(pg[j][s+a[i+1].l]+=v)%=p;
(pg[j][s+a[i+1].r+1]-=v)%=p;
}
for(int s=1+B;s<=B+B;s++){
int v=f[j][s];
(pf[s-b[j+1].r]+=v)%=p;
(pf[s-b[j+1].l+1]-=v)%=p;
}
for(int s=-B+B;s<=B+B;s++){
pf[s]=(s==0?pf[s]:pf[s]+pf[s-1])%p;
(f[j+1][s]+=pf[s])%=p;
}
for(int s=-B+B;s<=B+B;s++) pf[s]=0;
}
if(i!=0){
for(int j=1;j<=m;j++) cout<<(f[j][0+B]+p)%p<<" ";
cout<<endl;
}
}
return 0;
}
/*
Hello!!
Sample:
2 3
1 2
2 3
1 4
2 2
1 3
-------------------
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5776kb
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...