結果
問題 | No.30 たこやき工場 |
ユーザー |
![]() |
提出日時 | 2016-03-24 18:49:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 978 bytes |
コンパイル時間 | 919 ms |
コンパイル使用メモリ | 64,604 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 05:24:45 |
合計ジャッジ時間 | 1,352 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,n,0) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 100000000 typedef long long ll; vector<pair<unsigned int,int>> e[1500]; unsigned int s[100]; int n; bool root[101]; unsigned int dfs(int x) { if (x == n) return s[x] = 1; else if (s[x] > 0) return s[x]; else { for (auto p : e[x]) { s[x] += p.first*dfs(p.second); root[p.second] = false; } root[x] = true; return s[x]; } } int main() { int i, m; cin >> n >> m; rep (i,m) { int p, q, r; cin >> p >> q >> r; e[p].push_back(make_pair(q,r)); } rep (i,n) dfs(i); REP (i,1,n) { if (root[i]) cout << s[i] << endl; else cout << 0 << endl; } return 0; }