結果
問題 | No.1340 おーじ君をさがせ |
ユーザー | akasia_midori |
提出日時 | 2023-01-22 13:45:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,688 ms / 2,000 ms |
コード長 | 2,140 bytes |
コンパイル時間 | 283 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 81,280 KB |
最終ジャッジ日時 | 2024-06-24 18:34:02 |
合計ジャッジ時間 | 15,724 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
52,608 KB |
testcase_01 | AC | 44 ms
52,352 KB |
testcase_02 | AC | 43 ms
52,224 KB |
testcase_03 | AC | 42 ms
52,736 KB |
testcase_04 | AC | 43 ms
52,480 KB |
testcase_05 | AC | 43 ms
52,736 KB |
testcase_06 | AC | 43 ms
52,224 KB |
testcase_07 | AC | 43 ms
52,864 KB |
testcase_08 | AC | 43 ms
52,736 KB |
testcase_09 | AC | 43 ms
52,480 KB |
testcase_10 | AC | 64 ms
66,560 KB |
testcase_11 | AC | 159 ms
76,160 KB |
testcase_12 | AC | 85 ms
68,736 KB |
testcase_13 | AC | 349 ms
77,440 KB |
testcase_14 | AC | 260 ms
76,160 KB |
testcase_15 | AC | 227 ms
76,032 KB |
testcase_16 | AC | 82 ms
67,968 KB |
testcase_17 | AC | 122 ms
76,032 KB |
testcase_18 | AC | 161 ms
76,032 KB |
testcase_19 | AC | 65 ms
65,408 KB |
testcase_20 | AC | 59 ms
62,464 KB |
testcase_21 | AC | 183 ms
76,416 KB |
testcase_22 | AC | 1,213 ms
81,280 KB |
testcase_23 | AC | 387 ms
76,544 KB |
testcase_24 | AC | 1,688 ms
77,440 KB |
testcase_25 | AC | 92 ms
77,056 KB |
testcase_26 | AC | 88 ms
76,672 KB |
testcase_27 | AC | 82 ms
74,496 KB |
testcase_28 | AC | 97 ms
76,288 KB |
testcase_29 | AC | 74 ms
72,704 KB |
testcase_30 | AC | 192 ms
76,800 KB |
testcase_31 | AC | 611 ms
77,440 KB |
testcase_32 | AC | 540 ms
77,184 KB |
testcase_33 | AC | 536 ms
77,056 KB |
testcase_34 | AC | 584 ms
76,928 KB |
testcase_35 | AC | 699 ms
77,184 KB |
testcase_36 | AC | 45 ms
52,608 KB |
testcase_37 | AC | 66 ms
72,320 KB |
testcase_38 | AC | 571 ms
77,312 KB |
testcase_39 | AC | 217 ms
76,544 KB |
testcase_40 | AC | 215 ms
76,544 KB |
testcase_41 | AC | 217 ms
76,544 KB |
testcase_42 | AC | 51 ms
60,672 KB |
testcase_43 | AC | 51 ms
59,904 KB |
testcase_44 | AC | 58 ms
62,976 KB |
testcase_45 | AC | 54 ms
61,696 KB |
testcase_46 | AC | 214 ms
76,544 KB |
testcase_47 | AC | 226 ms
77,056 KB |
testcase_48 | AC | 248 ms
76,672 KB |
testcase_49 | AC | 192 ms
76,288 KB |
testcase_50 | AC | 201 ms
76,416 KB |
testcase_51 | AC | 200 ms
76,032 KB |
testcase_52 | AC | 289 ms
76,288 KB |
testcase_53 | AC | 279 ms
76,288 KB |
testcase_54 | AC | 284 ms
76,544 KB |
testcase_55 | AC | 302 ms
76,928 KB |
testcase_56 | AC | 57 ms
61,312 KB |
testcase_57 | AC | 56 ms
61,440 KB |
testcase_58 | AC | 44 ms
52,992 KB |
testcase_59 | AC | 131 ms
72,704 KB |
testcase_60 | AC | 43 ms
52,864 KB |
testcase_61 | AC | 131 ms
73,088 KB |
ソースコード
def oi(): return int(input()) def os(): return input() def mi(): return list(map(int, input().split())) import sys input = sys.stdin.readline # import sys # sys.setrecursionlimit(10**8) # import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') input_count = 0 def prod_func(a,b): if a*b > 0: return 1 return 0 def add_func(a,b): return a+b class MATRIX: def __init__(self, prod_func, add_func): self.prod_func = prod_func self.add_func = add_func def dot(self, A,B): if len(A[0]) != len(B): return None out = [[0] * len(B[0]) for _ in range(len(A))] for ay in range(len(A)): for bx in range(len(B[0])): sums = 0 for ax in range(len(A[0])): sums += self.prod_func(A[ay][ax], B[ax][bx]) out[ay][bx] = sums return out def sum(self, A,B): if not(len(A) == len(B) and len(A[0]) == len(B[0])): return None out = [] for ay in range(len(A)): temp = [] for ax in range(len(A[0])): temp.append(self.add_func(A[ay][ax], B[ay][ax])) out.append(temp) return out def prod(self, A,B): if not(len(A) == len(B) and len(A[0]) == len(B[0])): return None out = [] for ay in range(len(A)): temp = [] for ax in range(len(A[0])): temp.append(self.prod_func(A[ay][ax], B[ay][ax])) out.append(temp) return out # 正方行列AをN乗する。 def ruijou(self, A, N): out = [[0] * len(A) for _ in range(len(A))] for i in range(len(A)): out[i][i] = 1 while N: if N%2==1: out = self.dot(out, A) A = self.dot(A,A) N//=2 return out input_count = 0 N,M,T = mi() mat = [[0] * N for _ in range(N)] MAT = MATRIX(prod_func, add_func) for i in range(M): a,b = mi() mat[a][b] = 1 out = MAT.ruijou(mat, T) count = 0 for o in out[0]: if o>0: count += 1 print(count)