結果

問題 No.1878 union-find の数え上げ
ユーザー ytftytft
提出日時 2022-03-19 13:21:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 348 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 78,820 KB
最終ジャッジ日時 2024-04-15 02:31:43
合計ジャッジ時間 2,134 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda:sys.stdin.readline().rstrip()
def write(i,depth):
	if depth[i]!=-1:
		return
	write(par[i],depth)
	depth[i]=depth[par[i]]+1
mod=998244353
N=int(input())
par=[0]+[int(input())-1 for i in range(N-1)]
depth=[-1 for i in range(N)]
depth[0]=0
for i in range(1,N):
	write(i,depth)
ans=1
for i in depth:
	ans=(ans*i)%mod
print(ans)
0