結果
問題 | No.30 たこやき工場 |
ユーザー |
![]() |
提出日時 | 2023-06-01 22:30:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,366 bytes |
コンパイル時間 | 1,355 ms |
コンパイル使用メモリ | 127,012 KB |
最終ジャッジ日時 | 2025-02-13 17:20:50 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 TLE * 1 |
ソースコード
#include <iostream>#include <iomanip>#include <vector>#include <algorithm>#include <functional>#include <cmath>#include <string>#include <queue>#include <map>#include <bitset>#include <set>#include <stack>#include <numeric>#include <unordered_map>#include <random>using namespace std;using ll = long long;using vi = vector<int>;using vvi = vector<vi>;using vl = vector<ll>;using vvl = vector<vl>;using vb = vector<bool>;using vvb = vector<vb>;using vd = vector<double>;using vs = vector<string>;using pii = pair<int, int>;using pll = pair<ll, ll>;using pdd = pair<double, double>;using vpii = vector<pii>;using vpll = vector<pll>;using vpdd = vector<pdd>;const int inf = (1 << 30) - 1;const ll INF = 1LL << 60;//const int MOD = 1000000007;const int MOD = 998244353;struct Edge {int to;ll cost;};using Graph = vector<vector<Edge>>;void dfs(int s, Graph& g, ll cost, vl& ans) {if (g[s].size() == 0) {ans[s] += cost;}for (auto& v : g[s]) {dfs(v.to, g, cost * v.cost, ans);}}int main() {int n, m;cin >> n >> m;vi p(m), q(m), r(m);for (int i = 0; i < m; i++) {cin >> p[i] >> q[i] >> r[i];}vl ans(n + 1, 0);Graph g(n + 1);for (int i = 0; i < m; i++) {g[r[i]].push_back({ p[i], q[i] });}dfs(n, g, 1, ans);for (int i = 1; i < n; i++) {cout << ans[i] << endl;}return 0;}