結果
| 問題 |
No.912 赤黒木
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:07:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 647 bytes |
| コンパイル時間 | 269 ms |
| コンパイル使用メモリ | 82,272 KB |
| 実行使用メモリ | 108,408 KB |
| 最終ジャッジ日時 | 2025-06-12 16:07:24 |
| 合計ジャッジ時間 | 9,669 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 WA * 26 |
ソースコード
import sys
from collections import defaultdict
def main():
N = int(sys.stdin.readline())
red_edges = []
for _ in range(N-1):
u, v = map(int, sys.stdin.readline().split())
red_edges.append((u, v))
black_degrees = defaultdict(int)
for _ in range(N-1):
u, v = map(int, sys.stdin.readline().split())
black_degrees[u] += 1
black_degrees[v] += 1
count = 0
for v in black_degrees.values():
if v % 2 != 0:
count += 1
if count == 0:
print(N-1)
else:
k = count // 2
print(N + k - 2)
if __name__ == "__main__":
main()
gew1fw