結果

問題 No.1340 おーじ君をさがせ
ユーザー wolgnikwolgnik
提出日時 2021-01-15 22:26:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,294 ms / 2,000 ms
コード長 680 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 83,096 KB
最終ジャッジ日時 2023-08-18 16:39:12
合計ジャッジ時間 22,678 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,156 KB
testcase_01 AC 66 ms
70,920 KB
testcase_02 AC 67 ms
71,092 KB
testcase_03 AC 67 ms
70,916 KB
testcase_04 AC 67 ms
70,992 KB
testcase_05 AC 65 ms
70,976 KB
testcase_06 AC 67 ms
71,180 KB
testcase_07 AC 68 ms
71,340 KB
testcase_08 AC 68 ms
71,348 KB
testcase_09 AC 66 ms
71,108 KB
testcase_10 AC 83 ms
76,256 KB
testcase_11 AC 297 ms
78,396 KB
testcase_12 AC 123 ms
77,120 KB
testcase_13 AC 261 ms
78,552 KB
testcase_14 AC 517 ms
79,116 KB
testcase_15 AC 455 ms
78,780 KB
testcase_16 AC 110 ms
77,092 KB
testcase_17 AC 209 ms
78,124 KB
testcase_18 AC 313 ms
78,544 KB
testcase_19 AC 96 ms
76,332 KB
testcase_20 AC 83 ms
76,404 KB
testcase_21 AC 313 ms
78,992 KB
testcase_22 AC 691 ms
80,600 KB
testcase_23 AC 313 ms
79,124 KB
testcase_24 AC 1,221 ms
82,608 KB
testcase_25 AC 113 ms
77,832 KB
testcase_26 AC 102 ms
77,420 KB
testcase_27 AC 102 ms
77,564 KB
testcase_28 AC 129 ms
77,408 KB
testcase_29 AC 89 ms
76,692 KB
testcase_30 AC 343 ms
79,164 KB
testcase_31 AC 1,294 ms
83,096 KB
testcase_32 AC 1,156 ms
82,216 KB
testcase_33 AC 1,138 ms
82,296 KB
testcase_34 AC 1,019 ms
81,688 KB
testcase_35 AC 1,254 ms
82,244 KB
testcase_36 AC 69 ms
71,136 KB
testcase_37 AC 73 ms
76,076 KB
testcase_38 AC 1,269 ms
82,900 KB
testcase_39 AC 377 ms
78,888 KB
testcase_40 AC 374 ms
78,820 KB
testcase_41 AC 374 ms
78,416 KB
testcase_42 AC 70 ms
71,140 KB
testcase_43 AC 70 ms
75,764 KB
testcase_44 AC 77 ms
76,232 KB
testcase_45 AC 77 ms
76,124 KB
testcase_46 AC 290 ms
78,420 KB
testcase_47 AC 314 ms
78,288 KB
testcase_48 AC 344 ms
78,092 KB
testcase_49 AC 340 ms
78,332 KB
testcase_50 AC 338 ms
78,408 KB
testcase_51 AC 345 ms
78,460 KB
testcase_52 AC 621 ms
79,492 KB
testcase_53 AC 603 ms
79,212 KB
testcase_54 AC 609 ms
79,480 KB
testcase_55 AC 489 ms
79,020 KB
testcase_56 AC 75 ms
76,180 KB
testcase_57 AC 77 ms
76,336 KB
testcase_58 AC 72 ms
71,032 KB
testcase_59 AC 235 ms
77,976 KB
testcase_60 AC 71 ms
71,096 KB
testcase_61 AC 235 ms
77,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M, T = map(int, input().split())

bn = list(map(int, bin(T)[2: ]))
ln = len(bn)

d = [[[0] * N for _ in range(N)] for _ in range(ln)]
for _ in range(M):
  u, v = map(int, input().split())
  d[0][u][v] = 1

for t in range(ln - 1):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[t + 1][i][j] |= d[t][i][k] & d[t][k][j]

dt = [[0] * N for _ in range(N)]
dt[0][0] = 1
for tt in range(ln):
  t = ln - tt - 1
  if bn[tt] == 0: continue
  tdt = [[0] * N for _ in range(N)]
  for k in range(N):
    for i in range(N):
      for j in range(N):
        tdt[i][j] |= dt[i][k] & d[t][k][j]
  dt = tdt

print(sum(dt[0]))
0