Submission #43542854


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define op(x) ((x&1)?x+1:x-1)
#define odd(x) (x&1)
#define even(x) (!odd(x))
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
#define lowbit(x) (x&-x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
using namespace std;
const int MAXN = 410,mod = 998244353;

void add(ll& x,ll y){x=(x+y)%mod;}
ll addv(ll x,ll y){return (x+y)%mod;}

int n,m;

ll dp[2][MAXN][MAXN],f[MAXN][MAXN],sf[MAXN],g[MAXN][MAXN][2],C[MAXN][MAXN];

int main(){
	C[0][0]=1;
	rep(i,1,400){
		C[i][0]=1;
		rep(j,1,i)C[i][j] = addv(C[i-1][j-1],C[i-1][j]);
	}

	cin>>n>>m;

	per(i,n,1){
		memset(f,0,sizeof f);
		memset(g,0,sizeof g);
		memset(sf,0,sizeof sf);

		rep(j,1,m){
			rep(c,1,m)add(f[j][c],dp[(i+1)&1][j][c]);
			per(c,m,1)add(f[j][c],f[j][c+1]);

			add(sf[j],f[j][1]);
		}
		rep(j,1,m)add(sf[j],sf[j-1]);
		
		rep(j,1,m){
			rep(c,1,m)add(g[j][c][1],f[j][c]);
			add(g[j][1][1],sf[j-1]);
		}

		rep(j,1,m)rep(c,1,m)rep(k,0,1){
			add(g[j+1][c][0],g[j][c][k]);
			add(g[j+1][c+1][1],g[j][c][k]);
		}

		rep(j,1,m)rep(c,1,m){
			add(dp[i&1][j][c],g[j][c][1]);
			add(dp[i&1][j][c],C[j-1][c-1]);
			add(dp[i&1][j][c],dp[(i+1)&1][j][c]);



			dp[(i+1)&1][j][c] = 0;
		}
	}

	ll ans = 1;
	rep(j,1,m)rep(c,1,m)add(ans,dp[1][j][c]);

	cout<<ans<<endl;

    return 0;
}

Submission Info

Submission Time
Task F - Montage
User Crying
Language C++ (GCC 9.2.1)
Score 900
Code Size 1479 Byte
Status AC
Exec Time 957 ms
Memory 11348 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 3
AC × 36
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All 001-001.txt, 001-138.txt, 001-400.txt, 002-004.txt, 003-003.txt, 003-263.txt, 006-007.txt, 007-006.txt, 007-030.txt, 007-310.txt, 011-069.txt, 022-032.txt, 031-001.txt, 032-003.txt, 036-014.txt, 039-073.txt, 045-019.txt, 099-004.txt, 111-080.txt, 146-074.txt, 164-082.txt, 254-076.txt, 266-388.txt, 308-208.txt, 309-222.txt, 314-385.txt, 359-326.txt, 369-336.txt, 371-371.txt, 373-372.txt, 393-400.txt, 400-001.txt, 400-395.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
001-001.txt AC 16 ms 8756 KB
001-138.txt AC 9 ms 9628 KB
001-400.txt AC 14 ms 11324 KB
002-004.txt AC 8 ms 8692 KB
003-003.txt AC 10 ms 8768 KB
003-263.txt AC 14 ms 10348 KB
006-007.txt AC 11 ms 8660 KB
007-006.txt AC 9 ms 8764 KB
007-030.txt AC 12 ms 8860 KB
007-310.txt AC 22 ms 10716 KB
011-069.txt AC 11 ms 9168 KB
022-032.txt AC 12 ms 9004 KB
031-001.txt AC 22 ms 8820 KB
032-003.txt AC 14 ms 8756 KB
036-014.txt AC 15 ms 8752 KB
039-073.txt AC 18 ms 9076 KB
045-019.txt AC 22 ms 8776 KB
099-004.txt AC 24 ms 8752 KB
111-080.txt AC 41 ms 9260 KB
146-074.txt AC 46 ms 9280 KB
164-082.txt AC 54 ms 9284 KB
254-076.txt AC 73 ms 9296 KB
266-388.txt AC 614 ms 11280 KB
308-208.txt AC 252 ms 10116 KB
309-222.txt AC 281 ms 10096 KB
314-385.txt AC 708 ms 11140 KB
359-326.txt AC 606 ms 10764 KB
369-336.txt AC 653 ms 10832 KB
371-371.txt AC 779 ms 11064 KB
373-372.txt AC 789 ms 11048 KB
393-400.txt AC 939 ms 11348 KB
400-001.txt AC 66 ms 8752 KB
400-395.txt AC 936 ms 11288 KB
sample-01.txt AC 7 ms 8632 KB
sample-02.txt AC 8 ms 8936 KB
sample-03.txt AC 957 ms 11236 KB