結果

問題 No.2783 4-33 Easy
ユーザー tobbietobbie
提出日時 2024-07-26 15:39:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,244 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 178,480 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-26 15:39:06
合計ジャッジ時間 2,750 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 6 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 10 ms
5,376 KB
testcase_11 AC 9 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 9 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 9 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 10 ms
5,376 KB
testcase_19 AC 9 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 9 ms
5,376 KB
testcase_22 AC 9 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
using ll = long long int;
#define MOD 998244353
#define vvvi vector<vvi>
#define vvi vector<vi>
#define vi vector<int>
#define N 9

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> vo, vx;
  rep(i, n)
    cin >> a[i];
  rep(i, n) {
    string bi;
    cin >> bi;
    if (bi == "X") {
      b[i] = 0;
      vx.push_back(i);
    } else if (bi[(int)bi.size()-1] == 'X') {
      b[i] = stoi(bi.substr(0, (int)bi.size()-1));
      vx.push_back(i);
    } else {
      b[i] = stoi(bi);
      vo.push_back(i);
    }
  }
  vvvi v(N, vvi(5, vi(34, 0)));
  v[0][0][0] = 1;
  for (int i : vo) {
    for (int j = N-1; j >= 1; j--) {
      rep(k, 5) {
	rep(l, 34) {
	  if (v[j-1][k][l] == 0)
	    continue;
	  if (k+a[i] > 4)
	    continue;
	  if (l+b[i] > 33)
	    continue;
	  v[j][k+a[i]][l+b[i]] = ((ll)v[j][k+a[i]][l+b[i]] +
				  (ll)v[j-1][k][l]) % MOD;
	}
      }
    }
  }
  int ans = 0;
  for (int i : vx) {
    if (b[i] == 0) {
      ans = (v[N-1][4-a[i]][33-b[i]] + ans) % MOD;
    } else {
      if (33 - b[i] <= 4)
	ans = (v[N-1][4-a[i]][33-b[i]] + ans) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
0