結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー ThetaTheta
提出日時 2022-10-27 12:17:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,164 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,032 KB
実行使用メモリ 12,812 KB
最終ジャッジ日時 2023-09-18 05:58:16
合計ジャッジ時間 4,175 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,252 KB
testcase_01 AC 17 ms
7,868 KB
testcase_02 AC 17 ms
7,692 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class Town:
    def __init__(self, init: int):
        self.current = 0
        self.before = init
        self.neighbors = []

    def connect(self, other):
        self.neighbors.append(other)

    def next_career(self):
        self.current = sum(neighbor.before for neighbor in self.neighbors)

    def daily(self):
        self.before = self.current
        self.current = 0


class Network:
    def __init__(self, num: int):
        self.towns = [Town(0) for _ in range(num)]
        self.towns[0].before = 1
        self.day = 0

    def update(self):
        for town in self.towns:
            town.next_career()
        for town in self.towns:
            town.daily()
        self.day += 1

    def connect(self, num1: int, num2: int):
        self.towns[num1].connect(self.towns[num2])
        self.towns[num2].connect(self.towns[num1])


def main():
    N, M, T = map(int, input().split())
    network = Network(N)
    for _ in range(M):
        s, t = map(int, input().split())
        network.connect(s, t)

    while network.day < T:
        network.update()

    print(network.towns[0].before % 998244353)


if __name__ == "__main__":
    main()
0