結果

問題 No.1340 おーじ君をさがせ
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-12 17:42:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 606 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 86,716 KB
実行使用メモリ 90,772 KB
最終ジャッジ日時 2023-09-26 18:17:35
合計ジャッジ時間 13,625 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
75,524 KB
testcase_01 AC 89 ms
71,152 KB
testcase_02 AC 84 ms
71,092 KB
testcase_03 AC 77 ms
71,192 KB
testcase_04 AC 80 ms
71,372 KB
testcase_05 AC 81 ms
71,352 KB
testcase_06 AC 79 ms
71,332 KB
testcase_07 AC 81 ms
71,436 KB
testcase_08 AC 73 ms
71,232 KB
testcase_09 AC 85 ms
71,208 KB
testcase_10 AC 84 ms
75,952 KB
testcase_11 AC 88 ms
75,976 KB
testcase_12 AC 99 ms
76,148 KB
testcase_13 AC 82 ms
75,788 KB
testcase_14 AC 97 ms
76,248 KB
testcase_15 AC 80 ms
75,448 KB
testcase_16 AC 93 ms
76,156 KB
testcase_17 AC 82 ms
75,588 KB
testcase_18 AC 83 ms
75,532 KB
testcase_19 AC 79 ms
75,484 KB
testcase_20 AC 82 ms
76,116 KB
testcase_21 AC 221 ms
78,036 KB
testcase_22 AC 365 ms
77,940 KB
testcase_23 AC 214 ms
78,220 KB
testcase_24 AC 584 ms
78,116 KB
testcase_25 AC 125 ms
77,960 KB
testcase_26 AC 115 ms
78,032 KB
testcase_27 AC 112 ms
77,872 KB
testcase_28 AC 133 ms
78,180 KB
testcase_29 AC 124 ms
77,948 KB
testcase_30 AC 217 ms
78,076 KB
testcase_31 AC 606 ms
90,772 KB
testcase_32 AC 117 ms
78,000 KB
testcase_33 AC 120 ms
77,916 KB
testcase_34 AC 176 ms
78,164 KB
testcase_35 AC 176 ms
78,248 KB
testcase_36 AC 77 ms
71,332 KB
testcase_37 AC 127 ms
78,068 KB
testcase_38 AC 127 ms
78,152 KB
testcase_39 AC 504 ms
78,204 KB
testcase_40 AC 487 ms
85,536 KB
testcase_41 AC 477 ms
88,924 KB
testcase_42 AC 78 ms
71,264 KB
testcase_43 AC 74 ms
71,308 KB
testcase_44 AC 75 ms
71,260 KB
testcase_45 AC 74 ms
71,160 KB
testcase_46 AC 336 ms
78,352 KB
testcase_47 AC 334 ms
78,132 KB
testcase_48 AC 342 ms
78,368 KB
testcase_49 AC 457 ms
87,544 KB
testcase_50 AC 462 ms
87,384 KB
testcase_51 AC 467 ms
87,680 KB
testcase_52 AC 87 ms
76,012 KB
testcase_53 AC 89 ms
76,076 KB
testcase_54 AC 92 ms
75,856 KB
testcase_55 AC 198 ms
78,392 KB
testcase_56 AC 79 ms
71,272 KB
testcase_57 AC 84 ms
71,036 KB
testcase_58 AC 78 ms
70,960 KB
testcase_59 AC 85 ms
76,092 KB
testcase_60 AC 81 ms
71,260 KB
testcase_61 AC 87 ms
75,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main0(n,m,t,ab):
  # 愚直。ダブリング。O(n^2)
  g=[set() for _ in range(n)]
  for a,b in ab:
    g[a].add(b)
  ary=[[set()]*60 for _ in range(n)]
  # ary[v][k]:頂点vの2^k秒後にいる可能性のある頂点の集合
  for v in range(n):ary[v][0]=g[v]
  for k in range(1,60):
    for v in range(n):
      tmp=set()
      for u in ary[v][k-1]:
        tmp|=ary[u][k-1]
      ary[v][k]=tmp
  now={0}
  for i in range(60):
    if t&(1<<i):
      nxt=set()
      for v in now:
        nxt|=ary[v][i]
      now=nxt
  return len(now)

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