結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-22 21:28:53 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 767 bytes |
| コンパイル時間 | 912 ms |
| コンパイル使用メモリ | 119,804 KB |
| 実行使用メモリ | 23,756 KB |
| 最終ジャッジ日時 | 2024-06-13 04:23:50 |
| 合計ジャッジ時間 | 3,421 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 WA * 18 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
immutable long MOD = 10^^9 + 7;
void main() {
auto N = readln.chomp.to!int;
auto G = new int[][](N);
foreach (_; 0..N-1) {
auto s = readln.split.map!(to!int);
G[s[0]-1] ~= s[1]-1;
G[s[1]-1] ~= s[0]-1;
}
Tuple!(int, int) dfs(int n, int p, int d) {
Tuple!(int, int) ret = tuple(d, n);
foreach (m; G[n]) {
if (m == p) continue;
ret = max(ret, dfs(m, n, d+1));
}
return ret;
}
auto x = dfs(0, -1, 0);
auto y = dfs(x[1], -1, 0);
writeln(N - y[0] - 1);
}