結果
問題 |
No.30 たこやき工場
|
ユーザー |
![]() |
提出日時 | 2014-11-18 00:24:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 640 bytes |
コンパイル時間 | 748 ms |
コンパイル使用メモリ | 65,088 KB |
実行使用メモリ | 10,148 KB |
最終ジャッジ日時 | 2025-01-02 17:01:03 |
合計ジャッジ時間 | 7,765 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 TLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d %d", &N, &M); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d %d %d", &p, &q, &r); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream> #include <cstdio> #include <vector> typedef long long ll; struct Edge{ int to, cost; }; std::vector<Edge> G[101]; ll table[101]; void dfs(int u, ll k){ for(auto e : G[u]){ if(G[e.to].empty()){ table[e.to] += k * e.cost; } dfs(e.to, k*e.cost); } } int main(){ int N, M; scanf("%d %d", &N, &M); for(int i=0;i<M;i++){ int p, q, r; scanf("%d %d %d", &p, &q, &r); G[r].push_back({p, q}); } dfs(N, 1ll); for(int i=1;i<N;i++){ printf("%lld\n", table[i]); } }