結果

問題 No.1340 おーじ君をさがせ
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-12 16:42:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 1,188 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 83,424 KB
最終ジャッジ日時 2023-09-26 16:39:52
合計ジャッジ時間 28,624 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
76,164 KB
testcase_01 AC 80 ms
75,728 KB
testcase_02 AC 73 ms
71,352 KB
testcase_03 AC 75 ms
75,252 KB
testcase_04 WA -
testcase_05 AC 73 ms
70,940 KB
testcase_06 WA -
testcase_07 AC 79 ms
75,856 KB
testcase_08 AC 72 ms
71,160 KB
testcase_09 AC 73 ms
71,348 KB
testcase_10 AC 82 ms
76,064 KB
testcase_11 AC 210 ms
76,836 KB
testcase_12 WA -
testcase_13 AC 394 ms
78,736 KB
testcase_14 AC 388 ms
76,876 KB
testcase_15 AC 317 ms
76,960 KB
testcase_16 AC 131 ms
76,856 KB
testcase_17 AC 159 ms
76,796 KB
testcase_18 AC 236 ms
76,700 KB
testcase_19 AC 89 ms
76,232 KB
testcase_20 AC 88 ms
76,340 KB
testcase_21 AC 185 ms
78,656 KB
testcase_22 AC 677 ms
80,884 KB
testcase_23 AC 178 ms
78,600 KB
testcase_24 AC 468 ms
78,480 KB
testcase_25 AC 121 ms
78,072 KB
testcase_26 AC 117 ms
78,244 KB
testcase_27 AC 111 ms
78,104 KB
testcase_28 AC 123 ms
78,072 KB
testcase_29 AC 111 ms
77,960 KB
testcase_30 AC 190 ms
78,688 KB
testcase_31 AC 470 ms
78,776 KB
testcase_32 AC 496 ms
78,948 KB
testcase_33 AC 497 ms
79,028 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 71 ms
71,292 KB
testcase_37 AC 103 ms
77,856 KB
testcase_38 WA -
testcase_39 AC 1,501 ms
83,244 KB
testcase_40 AC 1,479 ms
83,128 KB
testcase_41 AC 1,457 ms
83,424 KB
testcase_42 WA -
testcase_43 AC 80 ms
76,108 KB
testcase_44 AC 81 ms
75,992 KB
testcase_45 AC 83 ms
75,736 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 1,190 ms
82,716 KB
testcase_49 AC 1,464 ms
81,100 KB
testcase_50 AC 1,461 ms
81,504 KB
testcase_51 AC 1,490 ms
81,364 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 78 ms
76,184 KB
testcase_57 AC 78 ms
76,324 KB
testcase_58 AC 74 ms
71,384 KB
testcase_59 WA -
testcase_60 AC 72 ms
71,216 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
  for i in range(63):
    if t&(1<<i):
      vc=dot(g,vc)
    g=dot(g,g)
  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