結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-08-20 15:56:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 922 bytes |
| コンパイル時間 | 1,564 ms |
| コンパイル使用メモリ | 166,700 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-21 05:20:05 |
| 合計ジャッジ時間 | 2,287 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
vector<ll> dp[111];
ll N, M;
vector<pair<ll, ll>> G[100]; // to, num
vector<ll> calc(int curr) {
if (dp[curr].size() > 0) return dp[curr];
vector<ll> res(N);
for (auto e : G[curr]) {
ll next = e.first;
ll num = e.second;
vector<ll> d = calc(next);
rep (i, N) {
res[i] += d[i] * num;
}
}
if (G[curr].size() == 0) {
res[curr] = 1;
}
return dp[curr] = res;
}
int main() {
cin >> N >> M;
rep (i, M) {
int p, q, r;
cin >> p >> q >> r;
p--; r--;
G[r].emplace_back(p, q);
}
auto res = calc(N - 1);
rep (i, N - 1) {
cout << res[i] << endl;
}
return 0;
}