結果

問題 No.1582 Vertexes vs Edges
ユーザー googol_S0googol_S0
提出日時 2021-07-02 21:53:17
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 104,136 KB
最終ジャッジ日時 2023-09-11 21:45:50
合計ジャッジ時間 8,643 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,204 KB
testcase_01 AC 68 ms
71,080 KB
testcase_02 AC 68 ms
71,200 KB
testcase_03 AC 70 ms
71,016 KB
testcase_04 AC 142 ms
76,848 KB
testcase_05 AC 186 ms
102,512 KB
testcase_06 AC 94 ms
78,468 KB
testcase_07 AC 97 ms
79,844 KB
testcase_08 AC 132 ms
87,820 KB
testcase_09 AC 175 ms
100,088 KB
testcase_10 AC 140 ms
90,796 KB
testcase_11 AC 92 ms
78,364 KB
testcase_12 AC 123 ms
86,228 KB
testcase_13 AC 159 ms
91,720 KB
testcase_14 AC 168 ms
91,908 KB
testcase_15 AC 195 ms
99,360 KB
testcase_16 AC 140 ms
86,468 KB
testcase_17 AC 164 ms
91,416 KB
testcase_18 AC 207 ms
103,176 KB
testcase_19 AC 153 ms
92,392 KB
testcase_20 AC 162 ms
90,452 KB
testcase_21 AC 142 ms
87,888 KB
testcase_22 AC 197 ms
100,512 KB
testcase_23 AC 124 ms
84,668 KB
testcase_24 AC 103 ms
80,172 KB
testcase_25 AC 151 ms
87,752 KB
testcase_26 AC 140 ms
85,976 KB
testcase_27 AC 208 ms
97,424 KB
testcase_28 AC 123 ms
83,976 KB
testcase_29 AC 188 ms
94,912 KB
testcase_30 AC 146 ms
86,868 KB
testcase_31 AC 191 ms
95,364 KB
testcase_32 AC 126 ms
84,396 KB
testcase_33 AC 247 ms
103,816 KB
testcase_34 AC 247 ms
104,132 KB
testcase_35 AC 241 ms
104,136 KB
testcase_36 AC 68 ms
71,280 KB
testcase_37 AC 67 ms
71,568 KB
testcase_38 AC 65 ms
71,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
  u,v=map(int,input().split())
  u-=1
  v-=1
  G[u].append(v)
  G[v].append(u)
DP=[[N,N] for i in range(N)]
def dfs(n,p):
  DP[n]=[0,0]
  for i in range(len(G[n])):
    if G[n][i]!=p:
      dfs(G[n][i],n)
      DP[n][0]+=min(DP[G[n][i]])
      DP[n][1]+=DP[G[n][i]][0]
  DP[n][0]+=1

dfs(0,-1)
print(min(DP[0]))
0