結果
| 問題 |
No.872 All Tree Path
|
| コンテスト | |
| ユーザー |
anagohirame
|
| 提出日時 | 2019-08-30 23:12:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 400 bytes |
| コンパイル時間 | 143 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 132,096 KB |
| 最終ジャッジ日時 | 2024-11-22 02:52:12 |
| 合計ジャッジ時間 | 18,806 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 RE * 1 |
ソースコード
import sys sys.setrecursionlimit(200000) n = int(input()) adj = [[] for _ in range(n)] for _ in range(n-1): u, v, w = map(int, input().split()) adj[u-1].append([v-1, w]) adj[v-1].append([u-1, w]) ans = 0 def dfs(x, parent): global ans child_num = 1 for c, w in adj[x]: if c == parent: continue d = dfs(c, x) ans += 2*d*(n-d)*w child_num += d return child_num dfs(0, -1) print(ans)
anagohirame