結果

問題 No.1111 コード進行
ユーザー recososorecososo
提出日時 2020-07-10 21:56:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,453 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 169,616 KB
実行使用メモリ 215,096 KB
最終ジャッジ日時 2024-04-19 17:01:15
合計ジャッジ時間 3,373 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 4 ms
5,760 KB
testcase_06 AC 3 ms
7,680 KB
testcase_07 AC 3 ms
7,192 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,888 KB
testcase_10 AC 5 ms
9,496 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 4 ms
7,424 KB
testcase_13 AC 3 ms
6,528 KB
testcase_14 AC 5 ms
9,912 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 5 ms
8,064 KB
testcase_17 AC 4 ms
9,856 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 4 ms
11,796 KB
testcase_23 AC 3 ms
6,144 KB
testcase_24 AC 4 ms
6,912 KB
testcase_25 AC 5 ms
11,176 KB
testcase_26 AC 4 ms
7,424 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 43 ms
108,796 KB
testcase_29 AC 18 ms
46,208 KB
testcase_30 AC 48 ms
72,780 KB
testcase_31 AC 8 ms
14,976 KB
testcase_32 AC 50 ms
65,152 KB
testcase_33 AC 44 ms
43,392 KB
testcase_34 AC 33 ms
78,848 KB
testcase_35 AC 39 ms
99,968 KB
testcase_36 AC 42 ms
107,264 KB
testcase_37 AC 12 ms
28,032 KB
testcase_38 AC 14 ms
21,760 KB
testcase_39 AC 73 ms
72,040 KB
testcase_40 AC 75 ms
98,444 KB
testcase_41 AC 44 ms
120,192 KB
testcase_42 AC 21 ms
50,048 KB
testcase_43 AC 38 ms
44,080 KB
testcase_44 AC 9 ms
24,928 KB
testcase_45 AC 25 ms
73,556 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 80 ms
215,096 KB
testcase_48 AC 3 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k;cin >> n >> m >> k;
    vector<int> p(m),q(m),c(m);
    vector<vector<pair<int,int>>> a(300);
    REP(i,m){
        cin >> p[i] >> q[i] >> c[i];
        p[i]--,q[i]--;
        a[p[i]].push_back({q[i],c[i]});
    }
    ll dp[n][k+1][300]={};
    REP(i,300){
        dp[0][0][i]=1;
    }
    REP(i,n-1){
        REP(j,k+1){
            REP(l,300){
                if(!dp[i][j][l]){
                    continue;
                }
                for(auto v:a[l]){
                    if(j+v.second<=k){
                        (dp[i+1][j+v.second][v.first]+=dp[i][j][l])%=mod;
                    }
                }
            }
        }
    }
    ll ans=0;
    REP(i,300){
        (ans+=dp[n-1][k][i])%=mod;
    }
    cout << ans << endl;
}
0