結果
| 問題 | No.1111 コード進行 |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-04-07 07:37:02 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 983 bytes |
| 記録 | |
| コンパイル時間 | 3,658 ms |
| コンパイル使用メモリ | 148,352 KB |
| 実行使用メモリ | 216,724 KB |
| 最終ジャッジ日時 | 2026-05-22 03:27:59 |
| 合計ジャッジ時間 | 11,809 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
コンパイルメッセージ
main.cpp:23:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
23 | int P[M];
| ^
main.cpp:23:9: note: read of non-const variable 'M' is not allowed in a constant expression
main.cpp:20:10: note: declared here
20 | int N, M, K;
| ^
main.cpp:24:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
24 | int Q[M];
| ^
main.cpp:24:9: note: read of non-const variable 'M' is not allowed in a constant expression
main.cpp:20:10: note: declared here
20 | int N, M, K;
| ^
main.cpp:25:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
25 | int C[M];
| ^
main.cpp:25:9: note: read of non-const variable 'M' is not allowed in a constant expression
main.cpp:20:10: note: declared here
20 | int N, M, K;
| ^
3 warnings generated.
ソースコード
#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;
const ll MOD = 1000000007;
ll dp[301][301][301];
int main() {
int N, M, K;
cin >> N >> M >> K;
int P[M];
int Q[M];
int C[M];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < M; ++i) {
cin >> P[i] >> Q[i] >> C[i];
dp[2][Q[i]][C[i]]++;
}
for (int i = 2; i < N; ++i) {
for (int j = 0; j < M; ++j) {
for (int k = K - C[j]; k >= 0; --k) {
int nk = k + C[j];
// fprintf(stderr, "i: %d, (%d -> %d) k: %d, cnt: %lld\n", i, P[j], Q[j], nk, dp[i][P[j]][k]);
dp[i + 1][Q[j]][nk] += dp[i][P[j]][k];
dp[i + 1][Q[j]][nk] %= MOD;
}
}
}
ll ans = 0;
for (int i = 0; i <= 300; ++i) {
ans += dp[N][i][K];
ans %= MOD;
}
cout << ans << endl;
return 0;
}
siman