結果
| 問題 |
No.1582 Vertexes vs Edges
|
| コンテスト | |
| ユーザー |
yuusanlondon
|
| 提出日時 | 2021-07-02 22:14:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 403 bytes |
| コンパイル時間 | 441 ms |
| コンパイル使用メモリ | 82,816 KB |
| 実行使用メモリ | 89,484 KB |
| 最終ジャッジ日時 | 2024-06-29 11:50:51 |
| 合計ジャッジ時間 | 6,626 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 33 |
ソースコード
n=int(input())
graph=[]
for i in range(n):
graph.append([])
for i in range(n-1):
a,b=map(int,input().split())
graph[a-1].append(b-1)
graph[b-1].append(a-1)
count0=0
count1=0
stack=[(0,0)]
visited=[0]*n
while stack:
v,co=stack.pop()
if co==0:
count0+=1
else:
count1+=1
visited[v]=1
for i in graph[v]:
if not visited[i]:
stack.append((i,1-co))
print(min(count0,count1))
yuusanlondon