結果

問題 No.1111 コード進行
ユーザー le_panda_noirle_panda_noir
提出日時 2020-07-19 13:33:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 1,534 bytes
コンパイル時間 1,036 ms
コンパイル使用メモリ 96,280 KB
実行使用メモリ 4,656 KB
最終ジャッジ日時 2023-08-22 09:54:33
合計ジャッジ時間 3,791 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,428 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 53 ms
4,656 KB
testcase_29 AC 23 ms
4,376 KB
testcase_30 AC 45 ms
4,444 KB
testcase_31 AC 8 ms
4,380 KB
testcase_32 AC 48 ms
4,380 KB
testcase_33 AC 45 ms
4,376 KB
testcase_34 AC 40 ms
4,376 KB
testcase_35 AC 49 ms
4,376 KB
testcase_36 AC 94 ms
4,564 KB
testcase_37 AC 24 ms
4,380 KB
testcase_38 AC 19 ms
4,376 KB
testcase_39 AC 71 ms
4,452 KB
testcase_40 AC 80 ms
4,376 KB
testcase_41 AC 63 ms
4,376 KB
testcase_42 AC 42 ms
4,380 KB
testcase_43 AC 42 ms
4,380 KB
testcase_44 AC 15 ms
4,376 KB
testcase_45 AC 44 ms
4,380 KB
testcase_46 AC 7 ms
4,376 KB
testcase_47 AC 241 ms
4,516 KB
testcase_48 AC 7 ms
4,376 KB
testcase_49 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

struct Graph {
  vector<map<int, long long>> edge;
  Graph(int n = 0) { resize(n); }
  void resize(int n) {
    edge.resize(n, map<int, long long>());
  }
  void addEdge(int from, int to, long long weight) {
    edge[from][to] = weight;
  }
  map<int, long long>& operator[](int from) { return edge[from]; }
};
template<int MOD> struct MInt {
  long long val;
  constexpr MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
constexpr int MOD = 1e9+7;
using mint = MInt<MOD>;


int main() {
  int N, M, K;
  ins(N, M, K);

  Graph G(300);
  rep(i, M) {
    int P, Q, C;
    ins(P, Q, C);
    --P, --Q;
    G.addEdge(P, Q, C);
  }
  vector<vector<mint>> memo(300, vector<mint>(K+1));

  rep(i, 300) {
    memo[i][0] = 1;
  }
  rep(n, N-1) {
    vector<vector<mint>> memo2(300, vector<mint>(K+1));
    rep(from, 300) rep(k, K+1)
      for (const auto& [to, c] : G[from]) {
        if (k-c >= 0)
          memo2[from][k] += memo[to][k-c];
      }
    swap(memo2, memo);
  }

  mint ans = 0;
  rep(from, 300)
    ans += memo[from][K];

  cout << ans << endl;

  return 0;
}
0