結果

問題 No.1582 Vertexes vs Edges
ユーザー convexineqconvexineq
提出日時 2021-07-03 06:02:35
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 98,476 KB
最終ジャッジ日時 2023-09-12 11:38:37
合計ジャッジ時間 8,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,332 KB
testcase_01 AC 74 ms
71,400 KB
testcase_02 AC 74 ms
71,368 KB
testcase_03 AC 75 ms
71,104 KB
testcase_04 AC 169 ms
77,904 KB
testcase_05 AC 180 ms
93,964 KB
testcase_06 AC 112 ms
77,872 KB
testcase_07 AC 118 ms
78,580 KB
testcase_08 AC 145 ms
85,408 KB
testcase_09 AC 176 ms
93,728 KB
testcase_10 AC 154 ms
86,576 KB
testcase_11 AC 116 ms
77,948 KB
testcase_12 AC 140 ms
83,992 KB
testcase_13 AC 170 ms
87,040 KB
testcase_14 AC 176 ms
87,168 KB
testcase_15 AC 207 ms
92,844 KB
testcase_16 AC 158 ms
84,540 KB
testcase_17 AC 167 ms
87,072 KB
testcase_18 AC 213 ms
97,216 KB
testcase_19 AC 158 ms
87,776 KB
testcase_20 AC 169 ms
86,244 KB
testcase_21 AC 155 ms
85,860 KB
testcase_22 AC 194 ms
93,636 KB
testcase_23 AC 141 ms
80,936 KB
testcase_24 AC 120 ms
78,464 KB
testcase_25 AC 160 ms
85,268 KB
testcase_26 AC 150 ms
83,656 KB
testcase_27 AC 212 ms
92,604 KB
testcase_28 AC 132 ms
80,300 KB
testcase_29 AC 199 ms
89,948 KB
testcase_30 AC 154 ms
85,224 KB
testcase_31 AC 200 ms
90,716 KB
testcase_32 AC 136 ms
81,236 KB
testcase_33 AC 259 ms
98,476 KB
testcase_34 AC 256 ms
98,292 KB
testcase_35 AC 260 ms
98,304 KB
testcase_36 AC 72 ms
71,284 KB
testcase_37 AC 73 ms
71,072 KB
testcase_38 AC 74 ms
71,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0