結果

問題 No.2783 4-33 Easy
ユーザー haihamabossuhaihamabossu
提出日時 2024-06-14 22:19:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,630 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 216,036 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-14 22:19:39
合計ジャッジ時間 3,601 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 9 ms
5,376 KB
testcase_05 AC 14 ms
5,376 KB
testcase_06 AC 13 ms
5,376 KB
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 13 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 12 ms
5,376 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 13 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 12 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 12 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 12 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 AC 13 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 13 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> c, d;
  {
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<string> b(n);
    rep(i, n) cin >> b[i];
    rep(i, n) {
      bool x = false;
      ll v = 0;
      rep(j, b[i].size()) {
        if (b[i][j] == 'X') {
          x = true;
        } else {
          v *= 10;
          v += b[i][j] - '0';
        }
      }
      if (x) {
        d.emplace_back(a[i], v);
      } else {
        c.emplace_back(a[i], v);
      }
    }
  }
  vector dp(10, vector(5, vector<mint>(34, 0)));
  dp[0][0][0] = 1;
  for (const auto &[a, b] : c) {
    vector pre = dp;
    rep(j, 5) {
      ll nj = j + a;
      if (nj >= 5)
        continue;
      rep(k, 34) {
        ll nk = k + b;
        if (nk >= 34)
          continue;
        rep(i, 8) {
          ll ni = i + 1;
          dp[ni][nj][nk] += pre[i][j][k];
        }
      }
    }
  }
  for (const auto &[a, b] : d) {
    rep(j, 5) {
      ll nj = j + a;
      if (nj != 4)
        continue;
      rep(k, 34) {
        ll nk = k + b;
        if (nk != 33)
          continue;
        if (b == 0 && k != 33)
          continue;
        if (b > 0 && k >= 5)
          continue;
        dp[9][4][33] += dp[8][4 - a][33 - b];
      }
    }
  }
  cout << dp[9][4][33].val() << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0