結果

問題 No.1340 おーじ君をさがせ
ユーザー ayaoniayaoni
提出日時 2021-01-16 02:39:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,243 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 81,528 KB
最終ジャッジ日時 2023-08-17 20:41:51
合計ジャッジ時間 18,671 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,044 KB
testcase_01 AC 76 ms
71,160 KB
testcase_02 AC 76 ms
71,248 KB
testcase_03 AC 76 ms
71,248 KB
testcase_04 WA -
testcase_05 AC 74 ms
71,296 KB
testcase_06 WA -
testcase_07 AC 75 ms
71,160 KB
testcase_08 AC 73 ms
71,456 KB
testcase_09 AC 75 ms
71,584 KB
testcase_10 AC 92 ms
76,220 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 321 ms
78,008 KB
testcase_14 AC 362 ms
77,264 KB
testcase_15 AC 315 ms
77,264 KB
testcase_16 WA -
testcase_17 AC 160 ms
77,088 KB
testcase_18 AC 221 ms
76,872 KB
testcase_19 AC 90 ms
76,120 KB
testcase_20 WA -
testcase_21 AC 227 ms
77,544 KB
testcase_22 AC 954 ms
81,528 KB
testcase_23 AC 226 ms
77,636 KB
testcase_24 AC 818 ms
78,272 KB
testcase_25 AC 105 ms
77,356 KB
testcase_26 AC 96 ms
76,864 KB
testcase_27 AC 96 ms
76,704 KB
testcase_28 AC 112 ms
77,268 KB
testcase_29 AC 91 ms
76,896 KB
testcase_30 AC 242 ms
77,764 KB
testcase_31 AC 819 ms
78,340 KB
testcase_32 AC 750 ms
78,112 KB
testcase_33 AC 741 ms
78,160 KB
testcase_34 AC 687 ms
78,216 KB
testcase_35 AC 809 ms
78,336 KB
testcase_36 AC 76 ms
71,136 KB
testcase_37 AC 86 ms
76,676 KB
testcase_38 AC 811 ms
78,604 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 84 ms
76,576 KB
testcase_45 AC 82 ms
76,136 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 245 ms
76,920 KB
testcase_50 AC 248 ms
76,928 KB
testcase_51 AC 248 ms
77,292 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 84 ms
76,140 KB
testcase_57 AC 83 ms
76,368 KB
testcase_58 AC 76 ms
71,352 KB
testcase_59 WA -
testcase_60 AC 76 ms
71,392 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


def matrix_multiplication(A,B):
    l = len(A)
    m = len(B)
    n = len(B[0])
    C = [[0]*n for _ in range(l)]
    for i in range(l):
        for j in range(n):
            for k in range(m):
                C[i][j] |= A[i][k] & B[k][j]
    return C


def matrix_power(A,n):
    l = len(A)
    C = [[0]*l for _ in range(l)]
    for i in range(l):
        C[i][i] = 1
    while n > 0:
        if n % 2 == 1:
            C = matrix_multiplication(C,A)
        A = matrix_multiplication(A,A)
        n >>= 1
    return C


N,M,T = MI()
Graph = [[0]*N for _ in range(N)]
for _ in range(M):
    a,b = MI()
    Graph[a][b] = 1

X = matrix_power(Graph,T)
initial_state = [[1]]+[[0]]*(N-1)

ANS = matrix_multiplication(X,initial_state)
ans = 0
for i in range(N):
    ans += ANS[i][0]

print(ans)
0