結果

問題 No.2164 Equal Balls
ユーザー 👑 chro_96chro_96
提出日時 2022-12-15 01:04:20
言語 C
(gcc 12.3.0)
結果
MLE  
実行時間 -
コード長 1,765 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 33,824 KB
実行使用メモリ 812,904 KB
最終ジャッジ日時 2024-04-26 04:57:34
合計ジャッジ時間 3,727 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int m = 0;
  int a[200000] = {};
  int b[200000] = {};
  
  int res = 0;
  
  long long dp[301][900001] = {};
  long long mod_num = 998244353LL;
  
  long long comb[301][301] = {};
  long long cnt[301][301][301] = {};
  
  long long prod[300][601] = {};
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    res = scanf("%d", a+i);
  }
  for (int i = 0; i < n; i++) {
    res = scanf("%d", b+i);
  }
  
  for (int i = 0; i <= 300; i++) {
    comb[i][0] = 1LL;
    comb[i][i] = 1LL;
    for (int j = 1; j < i; j++) {
      comb[i][j] = (comb[i-1][j-1]+comb[i-1][j])%mod_num;
    }
  }
  
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j <= 300; j++) {
      cnt[i][0][j] = comb[i][j];
    }
    for (int j = 1; j <= 300; j++) {
      for (int k = 0; k < 300; k++) {
        cnt[i][j][k] = (cnt[i][j-1][k]+cnt[i][j-1][k+1])%mod_num;
      }
      if (i >= 300) {
        cnt[i][j][300] = 1LL;
      }
    }
  }
  
  for (int i = 0; i < m; i++) {
    for (int j = 0; j <= 600; j++) {
      prod[i][j] = 1LL;
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 300; j++) {
      prod[i%m][j+300] *= cnt[a[i]][b[i]][j];
      prod[i%m][j+300] %= mod_num;
    }
    for (int j = 1; j <= 300; j++) {
      prod[i%m][300-j] *= cnt[b[i]][a[i]][j];
      prod[i%m][300-j] %= mod_num;
    }
  }
  
  dp[0][45000] = 1LL;
  for (int i = 0; i < m; i++) {
    int b = i+1;
    if (b > m-i-1) {
      b = m-i-1;
    }
    for (int j = -300*b; j <= 300*b; j++) {
      for (int k = -300; k <= 300; k++) {
        dp[i+1][j+45000] += dp[i][j+45000+k]*prod[i][k+300];
        dp[i+1][j+45000] %= mod_num;
      }
    }
  }
  
  printf("%lld\n", dp[m][45000]);
  return 0;
}
0