結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー S6136OS6136O
提出日時 2021-11-20 01:17:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 866 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 10,664 KB
実行使用メモリ 192,248 KB
最終ジャッジ日時 2023-08-30 14:08:19
合計ジャッジ時間 7,485 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,844 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 16 ms
7,832 KB
testcase_04 AC 578 ms
22,272 KB
testcase_05 AC 16 ms
7,792 KB
testcase_06 AC 17 ms
8,324 KB
testcase_07 AC 17 ms
8,208 KB
testcase_08 AC 16 ms
7,804 KB
testcase_09 AC 16 ms
7,808 KB
testcase_10 AC 176 ms
16,224 KB
testcase_11 AC 170 ms
15,972 KB
testcase_12 AC 741 ms
192,248 KB
testcase_13 AC 19 ms
8,212 KB
testcase_14 AC 40 ms
8,416 KB
testcase_15 AC 114 ms
9,912 KB
testcase_16 AC 204 ms
12,776 KB
testcase_17 AC 604 ms
59,788 KB
testcase_18 AC 866 ms
107,508 KB
testcase_19 AC 124 ms
13,864 KB
testcase_20 AC 39 ms
9,972 KB
testcase_21 AC 22 ms
8,484 KB
testcase_22 AC 16 ms
7,836 KB
testcase_23 AC 17 ms
7,836 KB
testcase_24 AC 18 ms
7,920 KB
testcase_25 AC 123 ms
13,568 KB
testcase_26 AC 51 ms
9,992 KB
testcase_27 AC 35 ms
9,176 KB
testcase_28 AC 597 ms
22,264 KB
testcase_29 AC 526 ms
20,368 KB
権限があれば一括ダウンロードができます

ソースコード

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