結果

問題 No.1111 コード進行
ユーザー beetbeet
提出日時 2020-07-10 21:32:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 2,295 bytes
コンパイル時間 2,334 ms
コンパイル使用メモリ 200,136 KB
実行使用メモリ 112,256 KB
最終ジャッジ日時 2024-04-19 15:53:18
合計ジャッジ時間 4,953 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
112,000 KB
testcase_01 AC 29 ms
112,128 KB
testcase_02 AC 29 ms
112,112 KB
testcase_03 AC 30 ms
112,000 KB
testcase_04 AC 29 ms
112,080 KB
testcase_05 AC 29 ms
112,000 KB
testcase_06 AC 29 ms
112,256 KB
testcase_07 AC 28 ms
112,000 KB
testcase_08 AC 28 ms
112,164 KB
testcase_09 AC 28 ms
112,000 KB
testcase_10 AC 29 ms
112,128 KB
testcase_11 AC 28 ms
112,000 KB
testcase_12 AC 29 ms
112,000 KB
testcase_13 AC 29 ms
112,000 KB
testcase_14 AC 29 ms
112,000 KB
testcase_15 AC 29 ms
112,128 KB
testcase_16 AC 29 ms
112,128 KB
testcase_17 AC 29 ms
112,172 KB
testcase_18 AC 28 ms
112,256 KB
testcase_19 AC 29 ms
112,220 KB
testcase_20 AC 29 ms
112,000 KB
testcase_21 AC 28 ms
112,000 KB
testcase_22 AC 30 ms
112,000 KB
testcase_23 AC 28 ms
112,128 KB
testcase_24 AC 28 ms
112,092 KB
testcase_25 AC 29 ms
112,000 KB
testcase_26 AC 29 ms
112,128 KB
testcase_27 AC 28 ms
112,128 KB
testcase_28 AC 29 ms
112,000 KB
testcase_29 AC 30 ms
112,000 KB
testcase_30 AC 31 ms
112,128 KB
testcase_31 AC 29 ms
112,000 KB
testcase_32 AC 32 ms
112,000 KB
testcase_33 AC 35 ms
112,128 KB
testcase_34 AC 29 ms
112,000 KB
testcase_35 AC 29 ms
112,084 KB
testcase_36 AC 43 ms
112,104 KB
testcase_37 AC 35 ms
112,128 KB
testcase_38 AC 33 ms
112,140 KB
testcase_39 AC 35 ms
112,256 KB
testcase_40 AC 39 ms
112,116 KB
testcase_41 AC 31 ms
112,128 KB
testcase_42 AC 39 ms
112,144 KB
testcase_43 AC 34 ms
112,000 KB
testcase_44 AC 31 ms
112,000 KB
testcase_45 AC 32 ms
112,236 KB
testcase_46 AC 29 ms
112,128 KB
testcase_47 AC 54 ms
112,128 KB
testcase_48 AC 30 ms
112,128 KB
testcase_49 AC 31 ms
112,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE

using M = Mint<int>;
const int MAX = 303;
M dp[MAX][MAX][MAX]={};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,m,k;
  cin>>n>>m>>k;

  using P = pair<int, int>;
  vector<vector<P>> G(MAX);
  for(int i=0;i<m;i++){
    int p,q,c;
    cin>>p>>q>>c;
    G[p].emplace_back(q,c);
  }

  for(int a=1;a<=300;a++)
    dp[1][a][0]=1;

  for(int i=1;i<n;i++)
    for(int a=1;a<=300;a++)
      for(auto [b,c]:G[a])
        for(int d=0;c+d<=k;d++)
          dp[i+1][b][c+d]+=dp[i][a][d];

  M ans{0};
  for(int a=1;a<=300;a++) ans+=dp[n][a][k];
  cout<<ans<<newl;
  return 0;
}
0