結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー mkawa2mkawa2
提出日時 2021-11-19 22:12:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,516 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 87,408 KB
実行使用メモリ 114,152 KB
最終ジャッジ日時 2023-08-30 08:47:31
合計ジャッジ時間 4,770 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,576 KB
testcase_01 AC 68 ms
71,400 KB
testcase_02 AC 72 ms
75,712 KB
testcase_03 AC 75 ms
71,584 KB
testcase_04 AC 140 ms
77,460 KB
testcase_05 AC 67 ms
71,428 KB
testcase_06 AC 71 ms
71,556 KB
testcase_07 AC 75 ms
71,336 KB
testcase_08 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 18446744073709551615
# inf = 4294967295
# md = 10**9+7
md = 998244353

def dot(aa, bb):
    h = len(aa)
    w = len(bb[0])
    res = [[0]*w for _ in range(h)]
    for i, row in enumerate(aa):
        for j, col in enumerate(zip(*bb)):
            v = 0
            # for a, b in zip(row, col): v += a*b
            # res[i][j] = v%md
            for a, b in zip(row, col): v += a*b%md
            res[i][j] = v%md
    return res

def matpow(mat, e):
    n = len(mat)
    res = [[1 if i == j else 0 for j in range(n)] for i in range(n)]
    while e:
        if e & 1: res = dot(res, mat)
        mat = dot(mat, mat)
        e >>= 1
    return res

n, m, t = LI()
base = [[0]*n for _ in range(n)]

for _ in range(m):
    u, v = LI()
    base[u][v] = 1
    base[v][u] = 1

mat = [[1 if i == j else 0 for j in range(n)] for i in range(n)]
while t:
    if t & 1: mat = dot(mat, base)
    base = dot(base, base)
    t >>= 1

print(mat[0][0])
0