結果

問題 No.2733 Just K-times TSP
ユーザー detteiuudetteiuu
提出日時 2024-04-24 21:19:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 793 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 141,312 KB
最終ジャッジ日時 2024-04-24 21:20:05
合計ジャッジ時間 5,423 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,480 KB
testcase_01 AC 36 ms
52,224 KB
testcase_02 AC 35 ms
51,968 KB
testcase_03 AC 35 ms
52,096 KB
testcase_04 AC 35 ms
51,840 KB
testcase_05 AC 34 ms
51,968 KB
testcase_06 AC 42 ms
52,480 KB
testcase_07 AC 36 ms
51,968 KB
testcase_08 AC 36 ms
52,352 KB
testcase_09 AC 47 ms
61,440 KB
testcase_10 AC 37 ms
52,096 KB
testcase_11 AC 37 ms
52,096 KB
testcase_12 AC 48 ms
63,104 KB
testcase_13 AC 46 ms
52,864 KB
testcase_14 AC 53 ms
65,152 KB
testcase_15 AC 56 ms
65,280 KB
testcase_16 AC 53 ms
63,616 KB
testcase_17 AC 77 ms
75,008 KB
testcase_18 AC 97 ms
83,200 KB
testcase_19 AC 115 ms
82,944 KB
testcase_20 AC 45 ms
62,336 KB
testcase_21 AC 66 ms
72,576 KB
testcase_22 AC 296 ms
141,312 KB
testcase_23 AC 87 ms
82,048 KB
testcase_24 AC 329 ms
108,544 KB
testcase_25 AC 280 ms
108,416 KB
testcase_26 AC 38 ms
52,608 KB
testcase_27 AC 63 ms
64,000 KB
testcase_28 AC 71 ms
69,248 KB
testcase_29 AC 82 ms
71,552 KB
testcase_30 AC 136 ms
82,304 KB
testcase_31 AC 273 ms
91,264 KB
testcase_32 AC 420 ms
108,416 KB
testcase_33 AC 793 ms
141,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    u, v = map(int, input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

MOD = 998244353
dp = [[0]*N for _ in range((K+1)**N)]
for i in range(N):
    dp[(K+1)**i][i] = 1

for i in range((K+1)**N):
    for j in range(N):
        if dp[i][j] >= 1:
            for v in G[j]:
                if i//((K+1)**v)%(K+1) < K:
                    dp[i+((K+1)**v)][v] += dp[i][j]
                    dp[i+((K+1)**v)][v] %= MOD

print(sum(dp[-1])%MOD)
0