QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#764360 | #5889. Equal Sums | konyakest | 0 | 0ms | 6992kb | C++17 | 2.5kb | 2024-11-20 08:49:23 | 2024-11-20 08:50:04 |
answer
#include<bits/stdc++.h>
#define F(i,j,k) for(auto i=j;i<=(decltype(i))k;i++)
#define x first
#define y second
#define exec(...) [&](){__VA_ARGS__}()
#define endl '\n'
#define os ostream
#define pb push_back
#define view(x) begin(x),end(x)
#define lambda [&]
using namespace std;
using ll=long long;
template<typename T>void ckmin(T& x,T y){x=min(x,y);}
template<typename T>void ckmax(T& x,T y){x=max(x,y);}
#ifdef DEBUG
template<typename T1,typename T2>os& operator<<(os&,pair<T1,T2>);
template<typename T,typename=decltype(T().begin()),typename=enable_if_t<!is_same_v<decay_t<T>,string>>>os& operator<<(os& out,T x){auto n=0u;out<<"{";for(auto i:x) out<<i<<(++n==x.size()?"":",");return out<<"}";}
template<typename ...T>os& operator<<(os& out,tuple<T...> x){return apply(lambda(T... x){auto n=0u;out<<"{";((out<<x<<(++n==sizeof...(T)?"":",")),...);},x),out<<"}";}
template<typename T1,typename T2>os& operator<<(os& out,pair<T1,T2> x){return out<<tuple(x);}
#define debug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<" = "<<std::make_tuple(__VA_ARGS__)<<endl
#else
#define debug(...) (void)0
#endif
const int maxn=505,mod=998244353;
int n,m;
pair<int,int> a[maxn],b[maxn];
int amb[maxn][maxn][maxn],bma[maxn][maxn][maxn];
signed main(){
#if not defined(DEBUG) and 0
#define FILENAME
[](...){}(freopen(FILENAME ".in","r",stdin),freopen(FILENAME ".out","w",stdout));
#endif
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
F(i,1,n) cin>>a[i].x>>a[i].y;
F(i,1,m) cin>>b[i].x>>b[i].y;
amb[0][0][0]=1,amb[0][0][1]=-1;
F(i,0,n) F(j,0,m){
F(k,1,500) (amb[i][j][k]+=amb[i][j][k-1])%=mod;
F(k,1,500) (bma[i][j][k]+=bma[i][j][k-1])%=mod;
if(i&&j) cout<<amb[i][j][0]<<" \n"[j==m];
F(k,0,500){
{
//amb[i][j+1][ k-b[j+1].y ... k-b[j+1].x ]++;
if(k-b[j+1].x>=0){
(amb[i][j+1][max(0,k-b[j+1].y)]+=amb[i][j][k])%=mod;
(amb[i][j+1][k-b[j+1].x+1]+=mod-amb[i][j][k])%=mod;
}
//bma[i][j+1][ b[j+1].x-k ... b[j+1].y-k ]++;
if(b[j+1].y-k>0){
(bma[i][j+1][max(1,b[j+1].x-k)]+=amb[i][j][k])%=mod;
(bma[i][j+1][b[j+1].y-k+1]+=mod-amb[i][j][k])%=mod;
}
}
{
//bma[i+1][j][ k-a[i+1].y ... k-a[i+1].x ]++;
if(k-a[i+1].x>0){
(bma[i+1][j][max(1,k-a[i+1].y)]+=bma[i][j][k])%=mod;
(bma[i+1][j][k-a[i+1].x+1]+=mod-bma[i][j][k])%=mod;
}
//amb[i+1][j][ a[i+1].x-k ... a[i+1].y-k ]++;
if(a[i+1].y-k>=0){
(amb[i+1][j][max(0,a[i+1].x-k)]+=bma[i][j][k])%=mod;
(amb[i+1][j][a[i+1].y-k+1]+=mod-bma[i][j][k])%=mod;
}
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6992kb
input:
10 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 20 120 266 858 1243 1657 1771 2328 2490 2665 2894 3117 4210 4454 4943 5690 6170 7048 7125 9512 9600 20 1688 52630 4512 628 1664 746 3690 4924 848 7959 2308 1896 4196 4582 3784 1062 4356 3176 4868 3702 20 42931 12638 7377 95960 39089 41765 3271...
output:
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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 256 0 0 0 0 0 0 ...
result:
wrong output format Expected 'Case' but found '0' (test case 1)
Subtask #2:
score: 0
Runtime Error
Test #2:
score: 0
Runtime Error
input:
10 500 214245260937 88701828170 983197677244 452707036056 745499471408 751327242016 445352756672 413854624384 799903000320 773052051968 241553140736 539361110016 722104184832 344346533888 249658261504 466496618496 715223269376 509944922112 686988460032 779287527424 438758801408 273785290752 43947497...