結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー S6136O
提出日時 2021-11-20 01:17:32
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,129 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 194,688 KB
最終ジャッジ日時 2025-01-02 04:47:30
合計ジャッジ時間 8,398 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

DIV = 998244353

# N : 都市の個数
# M : 道路の本数
# T : 目標の日数
N, M, T = map(lambda x: int(x), input().split())
T += 1

# 各都市同士のつながりをあらわす辞書
road = {}
for i in range(M):
    s, t = map(lambda x: int(x), input().split())
    if s in road:
        road[s].append(t)
    else:
        road[s] = [t]
    if t in road:
        road[t].append(s)
    else:
        road[t] = [s]

# 状態遷移テーブル
table = [[0] * N for i in range(T)]
# 都市0のT=0時点での初期値を設定
table[0][0] = 1

for t in range(1, T):
    for n in range(N):
        if table[t-1][n] == 0:
            continue
        if n not in road:
            continue
        for city in road[n]:
            table[t][city] += table[t-1][n]

# 結果表示
print(table[-1][0] % DIV)

0