結果

問題 No.763 Noelちゃんと木遊び
ユーザー tcltktcltk
提出日時 2021-08-24 05:29:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 82,632 KB
実行使用メモリ 178,216 KB
最終ジャッジ日時 2024-04-26 07:54:23
合計ジャッジ時間 6,548 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 318 ms
178,216 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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):

    delete = False
    for p1 in G[p]:
        if p1 == parent:
            continue
        dfs(p, p1)
        if Deleted[p1] == 0:
            delete = True

    Deleted[p] = delete


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 = [False] * N
dfs(-1, 0)

ans = Deleted.count(True)
print(ans)
0