結果
| 問題 | No.806 木を道に |
| コンテスト | |
| ユーザー |
双六
|
| 提出日時 | 2019-04-06 07:54:22 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 510 bytes |
| 記録 | |
| コンパイル時間 | 164 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 25,932 KB |
| 最終ジャッジ日時 | 2024-06-23 12:53:09 |
| 合計ジャッジ時間 | 7,359 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 1 WA * 26 |
ソースコード
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)
ans = -2
for i in g_a.graph:
if len(g_a.graph[i]) == 1:
ans += 1
print(ans)
双六