結果

問題 No.1964 sum = length
コンテスト
ユーザー siman
提出日時 2022-06-06 14:41:53
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 800 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 784 ms
コンパイル使用メモリ 148,992 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-09 11:59:07
合計ジャッジ時間 2,766 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:23:16: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   23 |   ll dp[N + 1][L + 1];
      |                ^~~~~
main.cpp:23:16: note: read of non-const variable 'L' is not allowed in a constant expression
main.cpp:22:7: note: declared here
   22 |   int L = 2 * N - 1;
      |       ^
main.cpp:23:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   23 |   ll dp[N + 1][L + 1];
      |         ^~~~~
main.cpp:23:9: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
   19 |   int N;
      |       ^
main.cpp:26:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   26 |   int C[L + 1];
      |         ^~~~~
main.cpp:26:9: note: read of non-const variable 'L' is not allowed in a constant expression
main.cpp:22:7: note: declared here
   22 |   int L = 2 * N - 1;
      |       ^
3 warnings generated.

ソースコード

diff #
raw source code

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

ll MOD = 998244353;

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

  int L = 2 * N - 1;
  ll dp[N + 1][L + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  int C[L + 1];
  memset(C, 0, sizeof(C));

  for (int i = 1; i <= L; ++i) {
    int v = i - i / 10;
    C[v]++;
  }

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= L; ++j) {
      for (int k = 1; k <= L; ++k) {
        int nj = j + k;
        if (nj > L) continue;

        dp[i + 1][nj] += dp[i][j] * C[k];
        dp[i + 1][nj] %= MOD;
      }
    }
  }

  cout << dp[N][L] << endl;

  return 0;
}
0