結果
| 問題 |
No.912 赤黒木
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:03:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 413 bytes |
| コンパイル時間 | 750 ms |
| コンパイル使用メモリ | 82,028 KB |
| 実行使用メモリ | 78,248 KB |
| 最終ジャッジ日時 | 2025-04-15 23:05:57 |
| 合計ジャッジ時間 | 8,119 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
lam6er