結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
双六
|
| 提出日時 | 2019-04-06 07:56:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 554 ms / 2,000 ms |
| コード長 | 533 bytes |
| コンパイル時間 | 91 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 32,796 KB |
| 最終ジャッジ日時 | 2024-06-23 12:56:22 |
| 合計ジャッジ時間 | 7,406 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
from collections import defaultdict
class Graph(object):
def __init__(self):
self.graph = defaultdict(list)
def __len__(self):
return len(self.graph)
def add_edge(self, a, b):
self.graph[a].append(b)
def get_nodes(self):
return self.graph.keys()
g_a = Graph()
N = int(input())
for i in range(N - 1):
a, b = list(map(int, input().split()))
g_a.add_edge(a, b)
g_a.add_edge(b, a)
ans = -2
for i in g_a.graph:
if len(g_a.graph[i]) == 1:
ans += 1
print(ans)
双六