結果
問題 | No.763 Noelちゃんと木遊び |
ユーザー |
|
提出日時 | 2022-05-05 18:03:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 292 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 82,460 KB |
実行使用メモリ | 180,480 KB |
最終ジャッジ日時 | 2024-07-04 19:34:22 |
合計ジャッジ時間 | 5,608 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#!/usr/bin/env python3import syssys.setrecursionlimit(10 ** 9)def main():N = int(input())G = [[] for _ in range(N)]dp = [0] * Nfor _ in range(N - 1):u, v = map(int, input().split())G[u - 1].append(v - 1)G[v - 1].append(u - 1)def dfs(now: int, pre: int):selectable = Truefor next in G[now]:if next == pre:continuedfs(next, now)if dp[next]:selectable = Falseif selectable:dp[now] = 1returndfs(0, -1)print(sum(dp))returnif __name__ == '__main__':main()