結果
| 問題 |
No.1103 Directed Length Sum
|
| コンテスト | |
| ユーザー |
tyawanmusi
|
| 提出日時 | 2020-07-03 22:04:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 372 bytes |
| コンパイル時間 | 330 ms |
| コンパイル使用メモリ | 82,520 KB |
| 実行使用メモリ | 340,116 KB |
| 最終ジャッジ日時 | 2024-09-17 02:03:49 |
| 合計ジャッジ時間 | 18,326 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | WA * 22 |
ソースコード
n=int(input())
edge=[[]for _ in range(n)]
to=[0]*n
p=[1]*n
for _ in range(n-1):
a,b=map(int,input().split())
a-=1
b-=1
edge[a].append(b)
to[b]+=1
stack=[i for i in range(n) if to[i]==0]
visited=set(stack)
for i in stack:
for j in edge[i]:
if j in visited:continue
visited.add(j)
to[j]-=1
if to[j]==0:stack.append(j)
p[j]+=p[i]
print(sum(p))
tyawanmusi