結果
| 問題 |
No.1103 Directed Length Sum
|
| コンテスト | |
| ユーザー |
yuruhiya
|
| 提出日時 | 2020-07-05 12:07:29 |
| 言語 | Crystal (1.14.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 352 bytes |
| コンパイル時間 | 11,288 ms |
| コンパイル使用メモリ | 296,040 KB |
| 実行使用メモリ | 95,380 KB |
| 最終ジャッジ日時 | 2024-06-30 20:29:09 |
| 合計ジャッジ時間 | 21,548 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 RE * 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 = (1..dist).sum
g[v].each do |u|
res += dfs(u, dist + 1, g)
end
res
end
puts dfs(flag.index(false).not_nil!, 0, g)
yuruhiya