結果

問題 No.1111 コード進行
ユーザー motmot
提出日時 2020-07-10 22:12:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 1,174 bytes
コンパイル時間 1,168 ms
コンパイル使用メモリ 90,912 KB
実行使用メモリ 219,008 KB
最終ジャッジ日時 2024-04-19 17:25:19
合計ジャッジ時間 4,108 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,632 KB
testcase_06 AC 7 ms
7,552 KB
testcase_07 AC 6 ms
7,040 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 5 ms
5,760 KB
testcase_10 AC 8 ms
9,216 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 7 ms
7,552 KB
testcase_13 AC 5 ms
6,400 KB
testcase_14 AC 11 ms
9,984 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 8 ms
8,192 KB
testcase_17 AC 9 ms
9,728 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 12 ms
11,776 KB
testcase_23 AC 5 ms
6,272 KB
testcase_24 AC 6 ms
6,784 KB
testcase_25 AC 13 ms
11,264 KB
testcase_26 AC 7 ms
7,680 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 123 ms
110,720 KB
testcase_29 AC 53 ms
47,616 KB
testcase_30 AC 91 ms
74,368 KB
testcase_31 AC 15 ms
14,976 KB
testcase_32 AC 86 ms
66,944 KB
testcase_33 AC 64 ms
44,416 KB
testcase_34 AC 88 ms
80,256 KB
testcase_35 AC 115 ms
102,528 KB
testcase_36 AC 152 ms
109,696 KB
testcase_37 AC 40 ms
29,056 KB
testcase_38 AC 29 ms
22,272 KB
testcase_39 AC 104 ms
73,344 KB
testcase_40 AC 133 ms
100,608 KB
testcase_41 AC 141 ms
122,880 KB
testcase_42 AC 76 ms
51,456 KB
testcase_43 AC 66 ms
45,056 KB
testcase_44 AC 34 ms
25,600 KB
testcase_45 AC 91 ms
75,392 KB
testcase_46 AC 4 ms
5,376 KB
testcase_47 AC 308 ms
219,008 KB
testcase_48 AC 5 ms
5,376 KB
testcase_49 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[305][305][305];

int main() {
  int N, M, K;
  cin>>N>>M>>K;
  vector<vector<pair<int, int> > > edge(305);
  ll P, Q, C;
  map<int, int> amap;
  for(int i=0;i<M;++i) {
    cin>>P>>Q>>C;
    P--;
    Q--;
    edge[P].push_back(mp(Q, C));
  }
  for(int i=0;i<305;++i){
    DP[0][0][i] = 1;
  }
  for(int i=0;i<N;++i){
    for(int j=0;j<=K;++j){
      for(int k=0;k<305;++k){
        for(int l=0;l<edge[k].size();++l){
          if(j+edge[k][l].se>K) continue;
          DP[i+1][j+edge[k][l].se][edge[k][l].fi] += DP[i][j][k];
          DP[i+1][j+edge[k][l].se][edge[k][l].fi] %= mod;
        }
      }
    }
  }
  ll ans = 0;
  for(int k=0;k<305;++k) {
    ans += DP[N-1][K][k];
    ans %= mod;
  }
  cout<<ans<<endl;
}

0