結果

問題 No.1111 コード進行
ユーザー k
提出日時 2020-09-04 23:16:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 482 ms / 2,000 ms
コード長 900 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 197,144 KB
最終ジャッジ日時 2025-01-14 06:26:38
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);
const long long MOD = 1e9 + 7;

int n, m, K;
vector<pair<int, int> > edges[301];
long long dp[301][301][301];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n >> m >> K;

  for (int i = 1; i <= 300; i++)
    edges[0].emplace_back(i, 0);
  
  REP (i, m) {
    int p, q, c;
    cin >> p >> q >> c;
    edges[p].emplace_back(q, c);
  }

  dp[0][0][0] = 1;

  REP (i, n) {
    REP (j, 301) REP (k, 301) {
      for (auto &pr: edges[j]) {
        if (k + pr.second <= K)
          (dp[i+1][pr.first][k + pr.second] += dp[i][j][k]) %= MOD;
      }
    }
  }

  long long ret = 0;
  REP (i, 301) (ret += dp[n][i][K]) %= MOD;
  cout << ret << endl;
  
  return 0;
}
0