結果
| 問題 |
No.2733 Just K-times TSP
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-20 12:48:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,068 bytes |
| コンパイル時間 | 323 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 279,292 KB |
| 最終ジャッジ日時 | 2024-10-12 08:12:14 |
| 合計ジャッジ時間 | 12,624 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 TLE * 1 |
ソースコード
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)