結果
| 問題 | No.1878 union-find の数え上げ |
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2022-03-19 13:22:11 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 355 bytes |
| 記録 | |
| コンパイル時間 | 613 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 83,072 KB |
| 最終ジャッジ日時 | 2026-04-20 07:25:14 |
| 合計ジャッジ時間 | 2,116 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
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*max(i,1))%mod print(ans)
ytft