結果
| 問題 |
No.2733 Just K-times TSP
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-04-19 23:28:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 861 bytes |
| コンパイル時間 | 418 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 241,140 KB |
| 最終ジャッジ日時 | 2024-10-11 18:08:17 |
| 合計ジャッジ時間 | 7,579 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 TLE * 1 -- * 15 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
from collections import Counter
mod=998244353
N,M,K=map(int,input().split())
E=[[] for i in range(N)]
for i in range(M):
u,v=map(int,input().split())
u-=1
v-=1
E[u].append(v)
E[v].append(u)
Q=[]
DP=Counter()
for i in range(N):
x=[i]+[0]*N
x[i+1]+=1
DP[tuple(x)]=1
Q.append((1,tuple(x)))
#print(DP)
USE=set()
while Q:
#print(DP)
SUM,L=heappop(Q)
if L in USE:
continue
USE.add(L)
#print(SUM,L)
L2=list(L[1:])
for to in E[L[0]]:
if L2[to]+1<=K:
L2[to]+=1
DP[tuple([to]+L2)]+=DP[L]
DP[tuple([to]+L2)]%=mod
heappush(Q,(SUM+1,tuple([to]+L2)))
L2[to]-=1
ANS=0
for i in range(N):
x=[i]+[K]*N
ANS+=DP[tuple(x)]
print(ANS%mod)
titia