結果

問題 No.1340 おーじ君をさがせ
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-12 16:40:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 83,072 KB
最終ジャッジ日時 2023-09-26 16:37:51
合計ジャッジ時間 27,699 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
76,396 KB
testcase_01 AC 79 ms
75,800 KB
testcase_02 AC 72 ms
71,212 KB
testcase_03 AC 80 ms
75,388 KB
testcase_04 WA -
testcase_05 AC 71 ms
71,168 KB
testcase_06 WA -
testcase_07 AC 80 ms
76,128 KB
testcase_08 AC 70 ms
71,020 KB
testcase_09 AC 77 ms
71,080 KB
testcase_10 AC 89 ms
76,136 KB
testcase_11 AC 214 ms
76,840 KB
testcase_12 WA -
testcase_13 AC 389 ms
78,284 KB
testcase_14 AC 381 ms
76,816 KB
testcase_15 AC 311 ms
76,648 KB
testcase_16 AC 132 ms
76,784 KB
testcase_17 AC 160 ms
76,816 KB
testcase_18 AC 235 ms
76,604 KB
testcase_19 AC 90 ms
76,276 KB
testcase_20 AC 88 ms
76,196 KB
testcase_21 AC 196 ms
78,648 KB
testcase_22 AC 662 ms
80,872 KB
testcase_23 AC 178 ms
78,776 KB
testcase_24 AC 461 ms
78,336 KB
testcase_25 AC 125 ms
78,164 KB
testcase_26 AC 116 ms
78,004 KB
testcase_27 AC 113 ms
77,988 KB
testcase_28 AC 125 ms
78,180 KB
testcase_29 AC 114 ms
77,944 KB
testcase_30 AC 190 ms
78,580 KB
testcase_31 AC 459 ms
78,800 KB
testcase_32 AC 479 ms
78,944 KB
testcase_33 AC 492 ms
79,016 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 73 ms
71,276 KB
testcase_37 AC 108 ms
77,912 KB
testcase_38 WA -
testcase_39 AC 1,447 ms
82,840 KB
testcase_40 AC 1,434 ms
83,072 KB
testcase_41 AC 1,425 ms
82,748 KB
testcase_42 WA -
testcase_43 AC 82 ms
76,316 KB
testcase_44 AC 84 ms
75,864 KB
testcase_45 AC 85 ms
76,140 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 1,169 ms
82,296 KB
testcase_49 AC 1,433 ms
80,976 KB
testcase_50 AC 1,418 ms
80,848 KB
testcase_51 AC 1,421 ms
80,960 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 78 ms
76,244 KB
testcase_57 AC 79 ms
76,280 KB
testcase_58 AC 73 ms
71,344 KB
testcase_59 WA -
testcase_60 AC 72 ms
71,160 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(60):
    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