結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー Theta
提出日時 2022-10-27 12:17:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 1,164 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 18,076 KB
最終ジャッジ日時 2024-07-04 22:17:06
合計ジャッジ時間 3,914 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 TLE * 1
other -- * 30
権限があれば一括ダウンロードができます

ソースコード

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