結果
問題 | No.763 Noelちゃんと木遊び |
ユーザー |
|
提出日時 | 2021-08-24 05:27:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 395 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 176,512 KB |
最終ジャッジ日時 | 2024-11-08 20:59:23 |
合計ジャッジ時間 | 7,669 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#!/usr/bin/env python3# from typing import *import sysimport ioimport mathimport collectionsimport decimalimport itertoolsimport bisectimport heapqdef input():return sys.stdin.readline()[:-1]sys.setrecursionlimit(1000000)# _INPUT = """12# 1 2# 2 3# 3 4# 4 5# 1 6# 6 7# 6 8# 7 11# 7 12# 8 9# 9 10# """# sys.stdin = io.StringIO(_INPUT)INF = 10**10def dfs(parent, p):leaf = Truefor p1 in G[p]:if p1 == parent:continuedfs(p, p1)if Deleted[p1] == 0:leaf = Falseif not leaf:Deleted[p] = 1N = int(input())G = [list() for _ in range(N)]for _ in range(N-1):u, v = map(int, input().split())G[u-1].append(v-1)G[v-1].append(u-1)Deleted = [0] * Ndfs(-1, 0)ans = Deleted.count(0)print(ans)