結果
問題 |
No.912 赤黒木
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:07:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 413 bytes |
コンパイル時間 | 444 ms |
コンパイル使用メモリ | 81,384 KB |
実行使用メモリ | 78,000 KB |
最終ジャッジ日時 | 2025-04-16 16:15:29 |
合計ジャッジ時間 | 7,669 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 WA * 26 |
ソースコード
n = int(input()) # Read red edges (not used) for _ in range(n-1): input() degree = [0] * (n + 1) # 1-based indexing # Read black edges and compute degrees for _ in range(n-1): c, d = map(int, input().split()) degree[c] += 1 degree[d] += 1 count = 0 for i in range(1, n+1): if degree[i] % 2 == 1: count += 1 k = count // 2 if count == 0: k = 1 ans = (n-1) + (k - 1) print(ans)