結果

問題 No.1111 コード進行
ユーザー yukudoyukudo
提出日時 2020-07-10 22:27:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,322 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 171,764 KB
実行使用メモリ 225,352 KB
最終ジャッジ日時 2023-08-01 18:29:01
合計ジャッジ時間 39,922 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
225,084 KB
testcase_01 AC 165 ms
225,072 KB
testcase_02 AC 167 ms
225,004 KB
testcase_03 WA -
testcase_04 AC 148 ms
225,060 KB
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 132 ms
225,052 KB
testcase_18 RE -
testcase_19 AC 131 ms
225,256 KB
testcase_20 AC 131 ms
225,256 KB
testcase_21 RE -
testcase_22 AC 132 ms
225,072 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 143 ms
225,120 KB
testcase_29 AC 136 ms
225,188 KB
testcase_30 RE -
testcase_31 WA -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 140 ms
225,072 KB
testcase_35 AC 149 ms
225,140 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 147 ms
225,080 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 100 ms
225,064 KB
testcase_47 AC 194 ms
225,012 KB
testcase_48 AC 102 ms
225,148 KB
testcase_49 AC 99 ms
225,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}


mint dp[305][305][305];

int main2() {

  REP(i, 305) REP(j, 305) REP(k, 305) dp[i][j][k] = 0;

  int N = nextLong();
  int M = nextLong();
  int K = nextLong();

  vector< vector< pair<int, int>> > g(N);
  REP(m, M) {
    int P = nextLong() - 1;
    int Q = nextLong() - 1;
    int C = nextLong();
    g[P].push_back({Q, C});

  }
  REP(i, N) dp[1][i][0] += 1;

  for (int i = 1; i < N; i++) {
    for (int m = 0; m < N; m++) {
      for (int k = 0; k <= K; k++) {
        for (auto e : g[m]) {
          if (k + e.second <= K) {
            dp[i+1][e.first][k + e.second] += dp[i][m][k];
          }
        }
      }
    }
  }

  mint ans = 0;
  REP(i, N) ans += dp[N][i][K];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}
0