結果
| 問題 |
No.1111 コード進行
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-10 21:47:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 331 ms / 2,000 ms |
| コード長 | 1,216 bytes |
| コンパイル時間 | 1,071 ms |
| コンパイル使用メモリ | 97,008 KB |
| 実行使用メモリ | 226,816 KB |
| 最終ジャッジ日時 | 2024-10-11 08:44:09 |
| 合計ジャッジ時間 | 4,149 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define int long long
#define endl "\n"
constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;
struct fast_io {
fast_io(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
};
} fio;
#define f first
#define s second
signed main(){
cout<<fixed<<setprecision(10);
const int MAX = 310;
int N, M, K;
vector<pair<pair<int,int>,int>> in;
vector<vector<vector<int>>> dp;
cin>>N>>M>>K;
in.resize(M);
dp.resize(N+1, vector<vector<int>>(K+1, vector<int>(MAX)));
for(int i = 0; i < M; i++){
cin>>in[i].f.f>>in[i].f.s>>in[i].s;
}
for(int i = 0; i < MAX; i++){
dp[0][0][i] = 1;
}
N--;
for(int i = 0; i < N; i++){
for(int j = 0; j < M; j++){
for(int k = 0; k <= K; k++){
if(in[j].s + k <= K) {
dp[i+1][in[j].s + k][in[j].f.s] += dp[i][k][in[j].f.f];
dp[i+1][in[j].s + k][in[j].f.s] %= MOD;
}
}
}
}
int ans = 0;
for(int i = 0; i < MAX; i++){
ans += dp[N][K][i];
// cout<<"i = "<<i<<" dp "<<dp[N][K][i]<<endl;
ans %= MOD;
}
cout<<ans<<endl;
return 0;
}