結果

問題 No.2164 Equal Balls
ユーザー 沙耶花沙耶花
提出日時 2022-12-15 22:05:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,450 ms / 5,000 ms
コード長 1,226 bytes
コンパイル時間 6,111 ms
コンパイル使用メモリ 274,096 KB
実行使用メモリ 237,976 KB
最終ジャッジ日時 2023-08-09 07:16:09
合計ジャッジ時間 51,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 309 ms
232,420 KB
testcase_01 AC 313 ms
232,556 KB
testcase_02 AC 315 ms
232,448 KB
testcase_03 AC 302 ms
232,396 KB
testcase_04 AC 303 ms
232,384 KB
testcase_05 AC 301 ms
232,412 KB
testcase_06 AC 300 ms
232,396 KB
testcase_07 AC 298 ms
232,428 KB
testcase_08 AC 345 ms
234,016 KB
testcase_09 AC 330 ms
233,332 KB
testcase_10 AC 319 ms
233,104 KB
testcase_11 AC 392 ms
235,824 KB
testcase_12 AC 347 ms
233,820 KB
testcase_13 AC 330 ms
233,464 KB
testcase_14 AC 341 ms
233,808 KB
testcase_15 AC 381 ms
234,544 KB
testcase_16 AC 344 ms
233,648 KB
testcase_17 AC 313 ms
232,636 KB
testcase_18 AC 357 ms
233,976 KB
testcase_19 AC 404 ms
235,576 KB
testcase_20 AC 357 ms
233,960 KB
testcase_21 AC 307 ms
232,508 KB
testcase_22 AC 309 ms
232,500 KB
testcase_23 AC 1,318 ms
234,236 KB
testcase_24 AC 719 ms
236,132 KB
testcase_25 AC 1,557 ms
233,368 KB
testcase_26 AC 497 ms
236,028 KB
testcase_27 AC 796 ms
236,764 KB
testcase_28 AC 806 ms
236,812 KB
testcase_29 AC 524 ms
233,392 KB
testcase_30 AC 782 ms
235,200 KB
testcase_31 AC 1,772 ms
233,884 KB
testcase_32 AC 850 ms
236,552 KB
testcase_33 AC 953 ms
233,336 KB
testcase_34 AC 948 ms
234,416 KB
testcase_35 AC 474 ms
232,616 KB
testcase_36 AC 1,399 ms
237,272 KB
testcase_37 AC 2,450 ms
234,076 KB
testcase_38 AC 1,048 ms
237,796 KB
testcase_39 AC 1,053 ms
237,900 KB
testcase_40 AC 1,062 ms
237,900 KB
testcase_41 AC 1,066 ms
237,964 KB
testcase_42 AC 1,069 ms
237,972 KB
testcase_43 AC 1,069 ms
237,848 KB
testcase_44 AC 1,059 ms
237,976 KB
testcase_45 AC 1,088 ms
237,796 KB
testcase_46 AC 1,069 ms
237,792 KB
testcase_47 AC 1,059 ms
237,848 KB
testcase_48 AC 1,071 ms
237,972 KB
testcase_49 AC 934 ms
233,448 KB
testcase_50 AC 929 ms
233,604 KB
testcase_51 AC 952 ms
233,784 KB
testcase_52 AC 942 ms
233,736 KB
testcase_53 AC 940 ms
233,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

mint cal[305][305][630];

int main(){
	
	int c = 315;
	rep(i,305){
		vector<mint> dp(630,0);
		dp[c] = 1;
		rep(j,i){
			vector<mint> ndp(630,0);
			rep(k,630){
				ndp[k] += dp[k];
				if(k!=629)ndp[k+1] += dp[k];
			}
			swap(dp,ndp);
		}
		vector<mint> tdp = dp;
		rep(j,305){
			rep(k,630){
				cal[i][j][k] += dp[k];
			}
			vector<mint> ndp(630,0);
			rep(k,630){
				ndp[k] += dp[k];
				if(k!=0)ndp[k-1] += dp[k];
			}
			swap(dp,ndp);
			
		}
		dp = tdp;
	}
	
	
	
	int N,M;
	cin>>N>>M;
	
	vector<int> a(N),b(N);
	rep(i,N)cin>>a[i];
	rep(i,N)cin>>b[i];
	
	queue<pair<vector<mint>,int>> Q;
	rep(i,M){
		vector<mint> t(630,1);
		rep(j,630){
			for(int k=i;k<N;k+=M){
				t[j] *= cal[a[k]][b[k]][j];
			}
		}
		Q.emplace(t,c);
	}
	//cout<<"A"<<endl;
	while(Q.size()>1){
		auto x = Q.front();
		Q.pop();
		auto y = Q.front();
		Q.pop();
		Q.emplace(convolution(x.first,y.first),x.second+y.second);
	}
	
	cout<<Q.front().first[Q.front().second].val()<<endl;
	
	return 0;
}
0