結果

問題 No.2733 Just K-times TSP
ユーザー titiatitia
提出日時 2024-04-20 00:54:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,121 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 188,920 KB
最終ジャッジ日時 2024-04-20 00:54:27
合計ジャッジ時間 6,583 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
69,860 KB
testcase_01 AC 53 ms
63,368 KB
testcase_02 AC 41 ms
55,792 KB
testcase_03 AC 41 ms
56,080 KB
testcase_04 AC 41 ms
55,440 KB
testcase_05 AC 41 ms
55,364 KB
testcase_06 AC 48 ms
64,188 KB
testcase_07 AC 39 ms
54,988 KB
testcase_08 AC 39 ms
55,496 KB
testcase_09 AC 80 ms
76,712 KB
testcase_10 AC 47 ms
61,840 KB
testcase_11 AC 46 ms
62,688 KB
testcase_12 AC 75 ms
77,024 KB
testcase_13 AC 60 ms
71,032 KB
testcase_14 AC 94 ms
77,680 KB
testcase_15 AC 97 ms
77,800 KB
testcase_16 AC 93 ms
77,448 KB
testcase_17 AC 383 ms
87,084 KB
testcase_18 AC 360 ms
87,480 KB
testcase_19 AC 424 ms
87,084 KB
testcase_20 AC 172 ms
80,252 KB
testcase_21 AC 296 ms
85,816 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from heapq import heappop,heappush
from collections import Counter
from itertools import product
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)

def enc(x):
    now=1
    ANS=0
    for i in range(1,len(x)):
        ANS+=now*x[i]
        now*=K+1
    ANS+=now*x[0]
    return ANS

def dec(x):
    X=[]
    for i in range(N):
        X.append(x%(K+1))
        x//=K+1
    X=[x]+X

    return X

DP=[0]*(((K+1)**N)*N)

for i in range(N):
    x=[i]+[0]*N
    x[i+1]+=1
    DP[enc(x)]=1


P=list(product(range(0,K+1),repeat=N))
P.sort(key=lambda x:sum(x))

for Y in P:
    for i in range(N):
        X=[i]+list(Y)
        k=DP[enc(X)]
        #print(X)

        for to in E[i]:
            if X[to+1]+1<=K:
                X[to+1]+=1
                X[0]=to
                #print("!",X)
                DP[enc(X)]=(DP[enc(X)]+k)%mod
                X[to+1]-=1

ANS=0
for i in range(N):
    x=[i]+[K]*N
    ANS+=DP[enc(x)]

print(ANS%mod)
        

    
0