結果
| 問題 | No.3852 Partition into 2-edge paths |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-04 01:11:33 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
TLE
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 698 bytes |
| 記録 | |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 64,444 KB |
| 実行使用メモリ | 427,772 KB |
| 最終ジャッジ日時 | 2026-12-04 20:55:29 |
| 合計ジャッジ時間 | 21,007 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 TLE * 3 |
ソースコード
import sys
sys.setrecursionlimit(2*10**7)
n=int(input())
v=[[] for i in range(2*n+1)]
for _ in range(2*n):
i,j=map(int,input().split())
i-=1
j-=1
v[i].append(j)
v[j].append(i)
childs=[1]*(2*n+1)
vis=set()
def calc_childs(i):
vis.add(i)
for j in v[i]:
if j not in vis:
calc_childs(j)
childs[i]+=childs[j]
calc_childs(0)
ans=1
vis=set()
def dfs(i):
global ans
vis.add(i)
cnt=0
for j in v[i]:
if j not in vis:
dfs(j)
if childs[j]%2==1:
cnt+=1
if cnt%2==0:
cnt-=1
while cnt>1:
ans*=cnt
ans%=998244353
cnt-=2
dfs(0)
print(ans)