結果

問題 No.1340 おーじ君をさがせ
ユーザー akasia_midoriakasia_midori
提出日時 2023-01-22 13:43:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,140 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 82,772 KB
最終ジャッジ日時 2023-09-07 00:15:24
合計ジャッジ時間 25,683 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,556 KB
testcase_01 WA -
testcase_02 AC 72 ms
71,372 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 69 ms
71,580 KB
testcase_07 WA -
testcase_08 AC 72 ms
71,332 KB
testcase_09 WA -
testcase_10 AC 83 ms
76,696 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 191 ms
77,964 KB
testcase_22 AC 1,134 ms
82,772 KB
testcase_23 AC 195 ms
77,648 KB
testcase_24 AC 622 ms
78,592 KB
testcase_25 AC 103 ms
77,540 KB
testcase_26 AC 99 ms
77,496 KB
testcase_27 AC 95 ms
77,668 KB
testcase_28 AC 106 ms
77,724 KB
testcase_29 AC 91 ms
77,092 KB
testcase_30 AC 205 ms
77,876 KB
testcase_31 AC 606 ms
78,708 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 82 ms
76,756 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 437 ms
77,808 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 79 ms
76,492 KB
testcase_57 AC 81 ms
76,328 KB
testcase_58 AC 70 ms
71,308 KB
testcase_59 WA -
testcase_60 AC 69 ms
71,344 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0