結果
| 問題 |
No.1582 Vertexes vs Edges
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-07-02 23:08:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 364 bytes |
| コンパイル時間 | 82 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 28,416 KB |
| 最終ジャッジ日時 | 2024-06-29 12:57:39 |
| 合計ジャッジ時間 | 7,575 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 33 |
ソースコード
import sys
input = sys.stdin.readline
N=int(input())
E=[[] for i in range(N)]
for i in range(N-1):
x,y=map(int,input().split())
x-=1
y-=1
E[x].append(y)
E[y].append(x)
Q=[0]
B=[-1]*N
B[0]=0
while Q:
x=Q.pop()
for to in E[x]:
if B[to]==-1:
Q.append(to)
B[to]=1-B[x]
print(min(B.count(0),B.count(1)))
titia