結果
| 問題 |
No.1582 Vertexes vs Edges
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2021-07-03 06:02:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 236 ms / 2,000 ms |
| コード長 | 415 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 82,088 KB |
| 実行使用メモリ | 97,352 KB |
| 最終ジャッジ日時 | 2024-06-30 00:06:29 |
| 合計ジャッジ時間 | 6,559 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
a,b = map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
order = []
st = [0]
parent = [-1]*n
while st:
v = st.pop()
order.append(v)
for c in g[v]:
if c != parent[v]:
st.append(c)
parent[c] = v
d = [0]*n
for i in order[1:][::-1]:
if d[i]==0: d[parent[i]] = 1
print(d.count(1))
convexineq