結果

問題 No.2980 Planar Tree 2
ユーザー kotatsugame
提出日時 2024-12-25 06:59:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 71,908 KB
実行使用メモリ 31,464 KB
最終ジャッジ日時 2025-06-20 11:26:05
合計ジャッジ時間 4,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N;
vector<int>G[2<<17];
mint ans=1;
void dfs(int u,int p)
{
	int sz=0;
	mint t=1;
	for(int v:G[u])if(v!=p)
	{
		t*=++sz;
		dfs(v,u);
	}
	ans*=t*(sz+1);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0,-1);
	mint t=G[0].size()+1;
	for(int i=1;i<N;i++)t*=i;
	ans/=t;
	cout<<ans.val()<<endl;
}
0