結果

問題 No.2733 Just K-times TSP
ユーザー flygonflygon
提出日時 2024-04-20 12:35:44
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 967 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,224 KB
実行使用メモリ 330,808 KB
最終ジャッジ日時 2024-04-20 12:35:53
合計ジャッジ時間 8,035 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
65,664 KB
testcase_01 AC 51 ms
61,952 KB
testcase_02 AC 46 ms
54,912 KB
testcase_03 AC 45 ms
54,656 KB
testcase_04 AC 45 ms
54,784 KB
testcase_05 AC 44 ms
54,528 KB
testcase_06 AC 48 ms
55,040 KB
testcase_07 AC 44 ms
54,272 KB
testcase_08 AC 46 ms
54,528 KB
testcase_09 AC 69 ms
72,832 KB
testcase_10 AC 45 ms
54,528 KB
testcase_11 AC 45 ms
54,400 KB
testcase_12 AC 52 ms
63,104 KB
testcase_13 AC 51 ms
62,208 KB
testcase_14 AC 92 ms
77,312 KB
testcase_15 AC 166 ms
82,944 KB
testcase_16 AC 72 ms
70,656 KB
testcase_17 AC 373 ms
114,944 KB
testcase_18 AC 709 ms
139,904 KB
testcase_19 AC 1,251 ms
180,480 KB
testcase_20 AC 55 ms
63,360 KB
testcase_21 AC 158 ms
85,632 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
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')

n,m,k = map(int,input().split())
graph = [[] for i in range(n+1)]
for i in range(m):
    u,v = map(int,input().split())
    graph[u-1].append(v-1)
    graph[v-1].append(u-1)
mod = 998244353
mem = dict()
def f(cnt, last):
    if max(cnt) == min(cnt) == k:
        return 1
    if tuple(cnt + [last]) in mem.keys():
        return mem[tuple(cnt + [last])]
    res = 0
    for nxt in graph[last]:
        if cnt[nxt] == k: continue
        new = cnt[::1]
        new[nxt] += 1
        res += f(new, nxt)
        res %= mod
    mem[tuple(cnt + [last])] = res
    return res
    
ans = 0
for i in range(n):
    cnt = [0]*n 
    cnt[i] += 1
    ans += f(cnt, i)
    ans %= mod


print(ans)
0