結果
問題 |
No.1103 Directed Length Sum
|
ユーザー |
![]() |
提出日時 | 2020-07-05 12:10:21 |
言語 | Crystal (1.14.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 362 bytes |
コンパイル時間 | 11,603 ms |
コンパイル使用メモリ | 295,964 KB |
実行使用メモリ | 138,428 KB |
最終ジャッジ日時 | 2024-06-30 20:28:13 |
合計ジャッジ時間 | 23,255 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 1 |
ソースコード
n = read_line.to_i g = Array.new(n) { [] of Int32 } flag = [false] * n n.pred.times do a, b = read_line.split.map &.to_i.pred g[a] << b flag[b] = true end def dfs(v : Int32, dist : Int32, g : Array(Array(Int32))) res = (1i64..dist.to_i64).sum g[v].each do |u| res += dfs(u, dist + 1, g) end res end puts dfs(flag.index(false).not_nil!, 0, g)