結果
問題 | No.763 Noelちゃんと木遊び |
ユーザー | tcltk |
提出日時 | 2021-08-24 05:27:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 330 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 245 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 176,896 KB |
最終ジャッジ日時 | 2024-04-26 07:52:46 |
合計ジャッジ時間 | 6,976 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 306 ms
176,896 KB |
testcase_01 | AC | 193 ms
93,184 KB |
testcase_02 | AC | 251 ms
98,432 KB |
testcase_03 | AC | 230 ms
95,964 KB |
testcase_04 | AC | 213 ms
93,696 KB |
testcase_05 | AC | 204 ms
95,636 KB |
testcase_06 | AC | 269 ms
100,736 KB |
testcase_07 | AC | 295 ms
100,480 KB |
testcase_08 | AC | 225 ms
96,256 KB |
testcase_09 | AC | 215 ms
93,696 KB |
testcase_10 | AC | 167 ms
90,948 KB |
testcase_11 | AC | 289 ms
100,736 KB |
testcase_12 | AC | 268 ms
99,840 KB |
testcase_13 | AC | 265 ms
99,556 KB |
testcase_14 | AC | 330 ms
98,496 KB |
testcase_15 | AC | 211 ms
95,616 KB |
testcase_16 | AC | 163 ms
90,880 KB |
testcase_17 | AC | 225 ms
95,416 KB |
testcase_18 | AC | 310 ms
100,636 KB |
testcase_19 | AC | 285 ms
99,668 KB |
testcase_20 | AC | 261 ms
100,096 KB |
ソースコード
#!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools import bisect import heapq def 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**10 def dfs(parent, p): leaf = True for p1 in G[p]: if p1 == parent: continue dfs(p, p1) if Deleted[p1] == 0: leaf = False if not leaf: Deleted[p] = 1 N = 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] * N dfs(-1, 0) ans = Deleted.count(0) print(ans)