結果

問題 No.2733 Just K-times TSP
ユーザー titiatitia
提出日時 2024-04-20 00:35:40
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,150 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 158,540 KB
最終ジャッジ日時 2024-04-20 00:36:17
合計ジャッジ時間 10,737 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
68,640 KB
testcase_01 AC 51 ms
62,464 KB
testcase_02 AC 42 ms
54,400 KB
testcase_03 AC 46 ms
54,528 KB
testcase_04 AC 41 ms
54,272 KB
testcase_05 AC 42 ms
54,272 KB
testcase_06 AC 41 ms
54,528 KB
testcase_07 AC 41 ms
54,272 KB
testcase_08 AC 43 ms
54,528 KB
testcase_09 AC 103 ms
77,532 KB
testcase_10 AC 43 ms
54,784 KB
testcase_11 AC 44 ms
54,400 KB
testcase_12 AC 63 ms
68,864 KB
testcase_13 AC 55 ms
64,896 KB
testcase_14 AC 169 ms
78,852 KB
testcase_15 AC 157 ms
78,172 KB
testcase_16 AC 90 ms
77,496 KB
testcase_17 AC 287 ms
85,480 KB
testcase_18 AC 413 ms
87,188 KB
testcase_19 AC 685 ms
91,156 KB
testcase_20 AC 51 ms
67,780 KB
testcase_21 AC 175 ms
83,720 KB
testcase_22 TLE -
testcase_23 AC 285 ms
84,504 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 48 ms
64,656 KB
testcase_27 AC 110 ms
77,656 KB
testcase_28 AC 154 ms
78,228 KB
testcase_29 AC 302 ms
81,240 KB
testcase_30 AC 737 ms
90,164 KB
testcase_31 AC 1,740 ms
110,644 KB
testcase_32 TLE -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)

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)
Q=[]
USE=[0]*(((K+1)**N)*N)
for i in range(N):
    x=[i]+[0]*N
    x[i+1]+=1
    DP[enc(x)]=1
    Q.append((1,enc(x)))
    USE[enc(x)]=1

while Q:
    S,i=heappop(Q)

    X=dec(i)
    #print(X,DP[i])
    kk=X[0]

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

            if USE[enc(X)]==0:
                heappush(Q,(S+1,enc(X)))
                USE[enc(X)]=1
            X[to+1]-=1

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

print(ANS%mod)
        

    
0