結果
問題 |
No.2427 Tree Distance Two
|
ユーザー |
|
提出日時 | 2023-08-18 21:38:24 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 640 ms / 2,000 ms |
コード長 | 367 bytes |
コンパイル時間 | 4,741 ms |
コンパイル使用メモリ | 174,208 KB |
実行使用メモリ | 39,936 KB |
最終ジャッジ日時 | 2024-11-28 06:09:18 |
合計ジャッジ時間 | 16,401 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
import std; void main(){ int n = readln.chomp.to!int; auto e = new int[][n]; for(auto i = 0; i < n - 1; i++){ auto input = readln.chomp.split.to!(int[]); e[input[0] - 1] ~= input[1] - 1; e[input[1] - 1] ~= input[0] - 1; } for(auto i = 0; i < n; i++){ auto s = 0; foreach(j; e[i]){ s += e[j].length - 1; } writeln(s); } }