結果
問題 |
No.1111 コード進行
|
ユーザー |
![]() |
提出日時 | 2020-07-11 01:24:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 863 ms |
コンパイル使用メモリ | 101,428 KB |
実行使用メモリ | 219,136 KB |
最終ジャッジ日時 | 2024-10-11 22:24:06 |
合計ジャッジ時間 | 4,352 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 WA * 9 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<utility> #include<map> #include<set> #include<queue> #include<stack> #include<functional> #include<math.h> #include<random> using namespace std; #define N (1000000000+7) #define M 998244353 #define INF 1e16 typedef long long ll; typedef pair<int,int> P; const int inf = (int)1e9; ll A(ll x){ if(x>=0)return x; else return -x; } ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } ll dp[305][305][305]; int main(void){ int n,m,k; cin>>n>>m>>k; vector<int>P(m),Q(m),C(m); for(int i=0;i<m;i++)cin>>P[i]>>Q[i]>>C[i]; for(int i=1;i<=300;i++)dp[0][i][0]=1; for(int i=0;i<n-1;i++){ for(int j=0;j<m;j++){ for(int x=0;x<=300;x++){ if(x>=C[j])dp[i+1][Q[j]][x]=(dp[i+1][Q[j]][x]+dp[i][P[j]][x-C[j]])%N; } } } ll ans = 0; for(int i=1;i<=300;i++){ ans = (ans+dp[n-1][i][k]); } cout<<ans<<endl; return 0; }