結果

問題 No.2783 4-33 Easy
ユーザー Y.Y.Y.Y.
提出日時 2024-06-09 21:34:03
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 968 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 88,620 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-14 20:49:33
合計ジャッジ時間 3,637 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
typedef string str;

#define MOD 998244353

int main() {
  ll N;
  cin >> N;

  vector<ll> A(N), B(N);
  for(ll i=0; i<N; i++){
    cin >> A[i];
    
    str temp;
    cin >> temp;
    
    if(temp == "X")
      B[i] = -1;
    else if(temp.back() == 'X')
      B[i] = -2;
    else
      B[i] = stoll(temp);
  }

  ll table[9][5][34];
  for(ll k=0; k<9; k++){
    for(ll a=0; a<5; a++){
      for(ll b=0; b<34; b++){
        table[k][a][b] = 0;
      }
    }
  }
  
  table[0][0][0] = 1;

  for(ll i=0; i<N; i++){
    if(B[i] < 0) continue;
    for(ll k=8; k>=0; k--){
      for(ll a=A[i]; a<5; a++){
        for(ll b=B[i]; b<34; b++){
          table[k][a][b] = (table[k][a][b]+table[k-1][a-A[i]][b-B[i]])%MOD;
        }
      }
    }
  }
  
  ll ans = 0;

  for(ll i=0; i<N; i++){
    if(B[i] == -1)
      ans = (ans+table[8][4-A[i]][33])%MOD;
  }

  cout << ans << endl;
  return 0;
}
0