結果

問題 No.1340 おーじ君をさがせ
ユーザー titiatitia
提出日時 2021-01-15 23:15:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,423 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 89,216 KB
最終ジャッジ日時 2023-08-18 16:46:30
合計ジャッジ時間 40,080 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
76,096 KB
testcase_01 AC 74 ms
76,004 KB
testcase_02 AC 68 ms
71,044 KB
testcase_03 AC 74 ms
75,244 KB
testcase_04 AC 77 ms
76,004 KB
testcase_05 AC 67 ms
71,112 KB
testcase_06 AC 73 ms
75,956 KB
testcase_07 AC 73 ms
76,072 KB
testcase_08 AC 67 ms
71,352 KB
testcase_09 AC 66 ms
71,168 KB
testcase_10 AC 77 ms
75,976 KB
testcase_11 AC 461 ms
83,420 KB
testcase_12 AC 146 ms
78,868 KB
testcase_13 AC 521 ms
83,152 KB
testcase_14 AC 1,063 ms
88,968 KB
testcase_15 AC 802 ms
84,144 KB
testcase_16 AC 124 ms
78,652 KB
testcase_17 AC 304 ms
78,832 KB
testcase_18 AC 551 ms
83,732 KB
testcase_19 AC 95 ms
76,176 KB
testcase_20 AC 81 ms
76,124 KB
testcase_21 AC 295 ms
78,260 KB
testcase_22 AC 859 ms
86,528 KB
testcase_23 AC 280 ms
78,332 KB
testcase_24 AC 1,353 ms
88,380 KB
testcase_25 AC 103 ms
78,028 KB
testcase_26 AC 99 ms
77,992 KB
testcase_27 AC 95 ms
77,624 KB
testcase_28 AC 116 ms
78,196 KB
testcase_29 AC 81 ms
76,564 KB
testcase_30 AC 326 ms
82,652 KB
testcase_31 AC 1,392 ms
88,148 KB
testcase_32 AC 1,337 ms
88,164 KB
testcase_33 AC 1,311 ms
88,016 KB
testcase_34 AC 1,256 ms
88,160 KB
testcase_35 AC 1,272 ms
88,168 KB
testcase_36 AC 67 ms
70,960 KB
testcase_37 AC 75 ms
76,180 KB
testcase_38 AC 1,404 ms
88,104 KB
testcase_39 AC 1,378 ms
88,144 KB
testcase_40 AC 1,354 ms
88,232 KB
testcase_41 AC 1,363 ms
88,336 KB
testcase_42 AC 75 ms
76,152 KB
testcase_43 AC 72 ms
75,896 KB
testcase_44 AC 73 ms
76,164 KB
testcase_45 AC 71 ms
76,068 KB
testcase_46 AC 1,376 ms
88,848 KB
testcase_47 AC 1,368 ms
88,780 KB
testcase_48 AC 1,370 ms
88,712 KB
testcase_49 AC 1,361 ms
89,216 KB
testcase_50 AC 1,381 ms
88,964 KB
testcase_51 AC 1,402 ms
89,104 KB
testcase_52 AC 1,410 ms
88,928 KB
testcase_53 AC 1,370 ms
88,776 KB
testcase_54 AC 1,386 ms
89,168 KB
testcase_55 AC 1,423 ms
88,756 KB
testcase_56 AC 74 ms
75,968 KB
testcase_57 AC 72 ms
75,948 KB
testcase_58 AC 65 ms
71,016 KB
testcase_59 AC 1,368 ms
89,160 KB
testcase_60 AC 64 ms
71,156 KB
testcase_61 AC 1,348 ms
89,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M,T=map(int,input().split())

mod=1+(1<<30)

# 行列の計算(numpyを使えないとき,modを使用)
def prod(A,B,k,l,m):# A:k*l,B:l*m
    C=[[None for i in range(m)] for j in range(k)]

    for i in range(k):
        for j in range(m):
            ANS=0
            for pl in range(l):
                ANS=(ANS+A[i][pl]*B[pl][j])%mod

            C[i][j]=ANS

    return C

def plus(A,B,k,l):# a,B:k*l
    C=[[None for i in range(l)] for j in range(k)]

    for i in range(k):
        for j in range(l):
            C[i][j]=(A[i][j]+B[i][j])%mod

    return C

A=[[0]*N for i in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    A[a][b]=1

# 漸化式を行列累乗で求める(ダブリング)

POWA=[A]

for i in range(60):
    POWA.append(prod(POWA[-1],POWA[-1],N,N,N)) # ベキを求めて


X=[[0]*N]
X[0][0]=1
#print(X)
while T:
    X=prod(X,POWA[T.bit_length()-1],1,N,N) # n乗の場合
    T-=1<<(T.bit_length()-1)

#print(X)

ANS=0
for i in X[0]:
    if i>0:
        ANS+=1

print(ANS)
    
0