結果

問題 No.2733 Just K-times TSP
ユーザー flygonflygon
提出日時 2024-04-20 12:48:33
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,068 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 82,136 KB
実行使用メモリ 273,788 KB
最終ジャッジ日時 2024-04-20 12:48:47
合計ジャッジ時間 11,965 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
60,160 KB
testcase_01 AC 43 ms
54,912 KB
testcase_02 AC 42 ms
55,040 KB
testcase_03 AC 42 ms
54,912 KB
testcase_04 AC 43 ms
54,400 KB
testcase_05 AC 44 ms
54,912 KB
testcase_06 AC 44 ms
54,656 KB
testcase_07 AC 43 ms
54,784 KB
testcase_08 AC 43 ms
54,632 KB
testcase_09 AC 56 ms
65,152 KB
testcase_10 AC 42 ms
54,912 KB
testcase_11 AC 43 ms
54,528 KB
testcase_12 AC 44 ms
55,040 KB
testcase_13 AC 43 ms
54,784 KB
testcase_14 AC 68 ms
71,552 KB
testcase_15 AC 85 ms
78,848 KB
testcase_16 AC 50 ms
61,952 KB
testcase_17 AC 135 ms
87,480 KB
testcase_18 AC 179 ms
97,792 KB
testcase_19 AC 284 ms
117,160 KB
testcase_20 AC 44 ms
55,040 KB
testcase_21 AC 92 ms
79,744 KB
testcase_22 AC 792 ms
249,536 KB
testcase_23 AC 135 ms
85,888 KB
testcase_24 AC 1,198 ms
257,100 KB
testcase_25 AC 1,022 ms
255,176 KB
testcase_26 AC 42 ms
54,656 KB
testcase_27 AC 68 ms
74,220 KB
testcase_28 AC 90 ms
77,824 KB
testcase_29 AC 132 ms
87,540 KB
testcase_30 AC 273 ms
112,364 KB
testcase_31 AC 717 ms
174,336 KB
testcase_32 AC 1,658 ms
266,240 KB
testcase_33 TLE -
権限があれば一括ダウンロードができます

ソースコード

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()
wa = 0
for i in range(n):
    wa += k*pow(10, i)
pows = [pow(10, i) for i in range(10)]
def f(cnt):
    if cnt//10 == wa:
        return 1
    if cnt in mem.keys():
        return mem[cnt]
    res = 0
    last = cnt % 10
    for nxt in graph[last]:
        now = (cnt//pows[nxt+1]) % 10
        if now == k: continue
        new = cnt//10
        new += pows[nxt]
        new = new*10 + nxt
        res += f(new)
        res %= mod
    mem[cnt] = res
    return res
    
ans = 0
for i in range(n):
    cnt = 0
    cnt += pow(10, i+1)
    ans += f(cnt+i)
    ans %= mod


print(ans)
0