結果

問題 No.1340 おーじ君をさがせ
ユーザー nephrologistnephrologist
提出日時 2021-01-15 23:15:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 80,512 KB
最終ジャッジ日時 2024-05-05 03:01:49
合計ジャッジ時間 17,563 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,096 KB
testcase_01 AC 37 ms
52,352 KB
testcase_02 AC 35 ms
52,096 KB
testcase_03 AC 37 ms
51,968 KB
testcase_04 WA -
testcase_05 AC 35 ms
52,096 KB
testcase_06 WA -
testcase_07 AC 38 ms
52,096 KB
testcase_08 AC 37 ms
52,096 KB
testcase_09 WA -
testcase_10 AC 51 ms
63,232 KB
testcase_11 AC 199 ms
75,904 KB
testcase_12 WA -
testcase_13 AC 271 ms
76,416 KB
testcase_14 AC 347 ms
76,160 KB
testcase_15 AC 332 ms
75,776 KB
testcase_16 AC 79 ms
66,176 KB
testcase_17 AC 139 ms
75,904 KB
testcase_18 AC 216 ms
76,032 KB
testcase_19 AC 55 ms
63,616 KB
testcase_20 AC 49 ms
61,696 KB
testcase_21 AC 226 ms
76,160 KB
testcase_22 AC 963 ms
80,512 KB
testcase_23 AC 223 ms
76,032 KB
testcase_24 AC 1,722 ms
76,544 KB
testcase_25 AC 84 ms
71,808 KB
testcase_26 AC 69 ms
69,120 KB
testcase_27 AC 62 ms
68,096 KB
testcase_28 AC 81 ms
73,216 KB
testcase_29 AC 53 ms
64,768 KB
testcase_30 AC 246 ms
75,904 KB
testcase_31 AC 1,077 ms
76,928 KB
testcase_32 AC 736 ms
76,544 KB
testcase_33 AC 740 ms
76,544 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 37 ms
52,224 KB
testcase_37 AC 45 ms
61,824 KB
testcase_38 WA -
testcase_39 AC 266 ms
76,288 KB
testcase_40 AC 272 ms
76,416 KB
testcase_41 AC 263 ms
76,672 KB
testcase_42 WA -
testcase_43 AC 43 ms
58,880 KB
testcase_44 AC 50 ms
60,800 KB
testcase_45 AC 42 ms
59,136 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 320 ms
76,032 KB
testcase_49 AC 288 ms
76,160 KB
testcase_50 AC 269 ms
76,032 KB
testcase_51 AC 284 ms
76,032 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 44 ms
59,648 KB
testcase_57 AC 43 ms
60,160 KB
testcase_58 AC 38 ms
52,096 KB
testcase_59 WA -
testcase_60 AC 37 ms
51,712 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline
#  nxnの行列積
# n is necessary


def matrix_product(A, B):
    res = [[0] * n for _ in range(n)]
    for i in range(n):
        for k in range(n):
            for j in range(n):
                res[i][j] += A[i][k] * B[k][j]
                if res[i][j]:
                    res[i][j] = 1
    return res


def matrix_exponents(A, t):
    res = [[0] * n for _ in range(n)]
    for i in range(n):
        res[i][i] = 1
    while t > 0:
        if t & 1 == 1:
            res = matrix_product(res, A)
        A = matrix_product(A, A)
        t //= 2
    return res


n, m, t = map(int, input().split())
if t==0:
    print(1)
    exit()
graph = [[0] * (n) for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a][b] = 1

res = matrix_exponents(graph, t - 1)
ans = 0

for j in range(n):
    if res[0][j]:
        ans += 1

print(ans)
0