結果

問題 No.1340 おーじ君をさがせ
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-12 17:39:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 80,720 KB
最終ジャッジ日時 2023-09-26 18:13:03
合計ジャッジ時間 15,150 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,292 KB
testcase_01 AC 75 ms
70,976 KB
testcase_02 AC 74 ms
71,156 KB
testcase_03 AC 73 ms
71,160 KB
testcase_04 WA -
testcase_05 AC 73 ms
71,472 KB
testcase_06 WA -
testcase_07 AC 74 ms
71,284 KB
testcase_08 AC 74 ms
71,204 KB
testcase_09 AC 72 ms
70,980 KB
testcase_10 AC 85 ms
76,272 KB
testcase_11 AC 144 ms
76,896 KB
testcase_12 WA -
testcase_13 AC 231 ms
77,352 KB
testcase_14 AC 233 ms
76,900 KB
testcase_15 AC 196 ms
76,932 KB
testcase_16 AC 109 ms
76,496 KB
testcase_17 AC 116 ms
75,944 KB
testcase_18 AC 149 ms
76,876 KB
testcase_19 AC 87 ms
76,240 KB
testcase_20 AC 85 ms
75,840 KB
testcase_21 AC 178 ms
78,620 KB
testcase_22 AC 659 ms
80,720 KB
testcase_23 AC 180 ms
78,568 KB
testcase_24 AC 438 ms
78,456 KB
testcase_25 AC 124 ms
78,100 KB
testcase_26 AC 118 ms
78,104 KB
testcase_27 AC 114 ms
78,280 KB
testcase_28 AC 123 ms
78,036 KB
testcase_29 AC 111 ms
78,036 KB
testcase_30 AC 186 ms
78,644 KB
testcase_31 AC 455 ms
78,740 KB
testcase_32 AC 454 ms
78,848 KB
testcase_33 AC 449 ms
78,884 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 73 ms
71,448 KB
testcase_37 AC 109 ms
77,948 KB
testcase_38 WA -
testcase_39 AC 245 ms
78,676 KB
testcase_40 AC 222 ms
78,676 KB
testcase_41 AC 222 ms
78,672 KB
testcase_42 WA -
testcase_43 AC 75 ms
75,176 KB
testcase_44 AC 80 ms
75,828 KB
testcase_45 AC 78 ms
76,088 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 265 ms
78,640 KB
testcase_49 AC 190 ms
76,968 KB
testcase_50 AC 214 ms
77,028 KB
testcase_51 AC 215 ms
76,816 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 79 ms
76,096 KB
testcase_57 AC 78 ms
75,492 KB
testcase_58 AC 73 ms
71,232 KB
testcase_59 WA -
testcase_60 AC 73 ms
71,040 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def dot(mtr0,mtr1):
  a,b=len(mtr0),len(mtr1[0])
  t=len(mtr0[0])
  if t!=len(mtr1):return None
  ret=[[0]*b for _ in range(a)]
  for i in range(a):
    for j in range(b):
      tmp=0
      for k in range(t):
        tmp+=mtr0[i][k]*mtr1[k][j]
        if tmp>0:tmp=1
      ret[i][j]=tmp
  return ret

def main0(n,m,t,ab):
  # ダブリング。O(n^2)
  g=[[0]*n for _ in range(n)]
  for a,b in ab:
    a,b=a-1,b-1
    g[b][a]=1
  vc=[[0] for _ in range(n)]
  vc[0][0]=1
  while t:
    if t%2==1:vc=dot(g,vc)
    g=dot(g,g)
    t>>=1
  ans=0
  for i in range(n):
    if vc[i][0]==1:
      ans+=1
  return ans
  
if __name__=='__main__':
  n,m,t=map(int,input().split())
  ab=[list(map(int,input().split())) for _ in range(m)]
  ret0=main0(n,m,t,ab)
  print(ret0)
0