結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー mkawa2mkawa2
提出日時 2021-11-19 22:50:40
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,299 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 87,160 KB
最終ジャッジ日時 2023-08-30 09:47:29
合計ジャッジ時間 28,062 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,164 KB
testcase_01 AC 76 ms
71,392 KB
testcase_02 AC 86 ms
75,376 KB
testcase_03 AC 84 ms
76,096 KB
testcase_04 AC 153 ms
77,136 KB
testcase_05 AC 74 ms
71,528 KB
testcase_06 AC 76 ms
71,456 KB
testcase_07 AC 77 ms
71,288 KB
testcase_08 AC 449 ms
79,004 KB
testcase_09 AC 452 ms
78,920 KB
testcase_10 AC 450 ms
78,784 KB
testcase_11 AC 371 ms
78,492 KB
testcase_12 AC 493 ms
79,120 KB
testcase_13 AC 474 ms
79,064 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,510 ms
84,000 KB
testcase_21 AC 1,636 ms
85,252 KB
testcase_22 AC 414 ms
78,352 KB
testcase_23 TLE -
testcase_24 AC 325 ms
77,844 KB
testcase_25 AC 678 ms
79,816 KB
testcase_26 AC 282 ms
77,420 KB
testcase_27 AC 93 ms
76,264 KB
testcase_28 AC 103 ms
76,848 KB
testcase_29 AC 93 ms
76,100 KB
testcase_30 AC 404 ms
78,656 KB
testcase_31 AC 386 ms
77,992 KB
testcase_32 AC 379 ms
78,268 KB
testcase_33 AC 374 ms
78,316 KB
権限があれば一括ダウンロードができます

ソースコード

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

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