結果

問題 No.1340 おーじ君をさがせ
ユーザー chineristACchineristAC
提出日時 2021-01-15 21:53:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,715 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 82,320 KB
最終ジャッジ日時 2023-08-18 16:35:27
合計ジャッジ時間 8,580 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,424 KB
testcase_01 AC 65 ms
71,268 KB
testcase_02 AC 65 ms
71,572 KB
testcase_03 AC 65 ms
71,392 KB
testcase_04 AC 65 ms
71,272 KB
testcase_05 AC 67 ms
71,356 KB
testcase_06 AC 64 ms
71,360 KB
testcase_07 AC 66 ms
71,316 KB
testcase_08 AC 65 ms
71,332 KB
testcase_09 AC 64 ms
71,576 KB
testcase_10 AC 78 ms
75,976 KB
testcase_11 AC 135 ms
78,064 KB
testcase_12 AC 104 ms
76,596 KB
testcase_13 AC 205 ms
78,136 KB
testcase_14 AC 180 ms
78,184 KB
testcase_15 AC 160 ms
78,096 KB
testcase_16 AC 97 ms
76,512 KB
testcase_17 AC 107 ms
77,724 KB
testcase_18 AC 128 ms
77,920 KB
testcase_19 AC 79 ms
76,236 KB
testcase_20 AC 78 ms
76,004 KB
testcase_21 AC 203 ms
78,916 KB
testcase_22 AC 821 ms
82,272 KB
testcase_23 AC 200 ms
79,124 KB
testcase_24 AC 1,715 ms
82,320 KB
testcase_25 AC 109 ms
77,904 KB
testcase_26 AC 101 ms
77,944 KB
testcase_27 AC 99 ms
77,664 KB
testcase_28 AC 111 ms
77,800 KB
testcase_29 AC 94 ms
77,704 KB
testcase_30 AC 214 ms
79,508 KB
testcase_31 AC 597 ms
82,136 KB
testcase_32 AC 352 ms
81,988 KB
testcase_33 AC 353 ms
81,972 KB
testcase_34 AC 525 ms
82,248 KB
testcase_35 AC 616 ms
81,980 KB
testcase_36 AC 66 ms
71,576 KB
testcase_37 AC 89 ms
77,188 KB
testcase_38 AC 358 ms
82,004 KB
testcase_39 AC 224 ms
77,892 KB
testcase_40 AC 229 ms
78,080 KB
testcase_41 AC 223 ms
78,076 KB
testcase_42 AC 68 ms
75,672 KB
testcase_43 AC 67 ms
75,132 KB
testcase_44 AC 70 ms
76,216 KB
testcase_45 AC 72 ms
76,144 KB
testcase_46 AC 223 ms
77,904 KB
testcase_47 AC 237 ms
78,012 KB
testcase_48 AC 264 ms
78,000 KB
testcase_49 AC 179 ms
78,072 KB
testcase_50 AC 184 ms
78,136 KB
testcase_51 AC 183 ms
77,844 KB
testcase_52 AC 199 ms
78,164 KB
testcase_53 AC 191 ms
78,528 KB
testcase_54 AC 191 ms
78,300 KB
testcase_55 AC 306 ms
78,256 KB
testcase_56 AC 71 ms
76,060 KB
testcase_57 AC 72 ms
76,172 KB
testcase_58 AC 67 ms
71,372 KB
testcase_59 AC 113 ms
77,272 KB
testcase_60 AC 65 ms
71,672 KB
testcase_61 AC 113 ms
77,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mmult(A, B):
    n, m, l = len(A), len(B), len(B[0])
    ret = [[0]*l for _ in range(n)]
    for i in range(n):
        for j in range(m):
            for k in range(l):
                if A[i][j] and B[j][k]:
                    ret[i][k] = 1
    return ret
def mpow(A, n):
    if n == 0: return [[1 if i == j else 0 for j in range(len(A))] for i in range(len(A))]
    if n % 2: return mmult(mpow(A, n-1), A)
    return mpow(mmult(A, A), n//2)

N,M,T = map(int,input().split())
A = [[0 for j in range(N)] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if not A[b][a]:
        A[b][a] = 1

A = mpow(A,T)
B = [[1]] + [[0]] * (N-1)
A = mmult(A,B)

res = 0
for i in range(N):
    if A[i][0]:
        res += 1

print(res)
0