結果
問題 | No.1340 おーじ君をさがせ |
ユーザー | chineristAC |
提出日時 | 2021-01-15 21:45:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,394 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 82,168 KB |
実行使用メモリ | 84,448 KB |
最終ジャッジ日時 | 2024-05-05 02:37:25 |
合計ジャッジ時間 | 15,783 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,120 KB |
testcase_01 | AC | 35 ms
52,992 KB |
testcase_02 | AC | 34 ms
52,736 KB |
testcase_03 | AC | 37 ms
52,992 KB |
testcase_04 | WA | - |
testcase_05 | AC | 41 ms
53,120 KB |
testcase_06 | WA | - |
testcase_07 | AC | 34 ms
53,452 KB |
testcase_08 | AC | 34 ms
52,608 KB |
testcase_09 | AC | 37 ms
53,120 KB |
testcase_10 | AC | 59 ms
69,632 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 258 ms
77,440 KB |
testcase_14 | AC | 228 ms
76,672 KB |
testcase_15 | AC | 198 ms
76,320 KB |
testcase_16 | WA | - |
testcase_17 | AC | 104 ms
76,288 KB |
testcase_18 | AC | 140 ms
76,160 KB |
testcase_19 | AC | 54 ms
68,352 KB |
testcase_20 | WA | - |
testcase_21 | AC | 343 ms
78,972 KB |
testcase_22 | AC | 1,282 ms
81,816 KB |
testcase_23 | AC | 339 ms
78,944 KB |
testcase_24 | TLE | - |
testcase_25 | AC | 94 ms
76,908 KB |
testcase_26 | AC | 85 ms
76,544 KB |
testcase_27 | AC | 82 ms
76,980 KB |
testcase_28 | AC | 106 ms
76,672 KB |
testcase_29 | AC | 69 ms
76,616 KB |
testcase_30 | AC | 382 ms
78,720 KB |
testcase_31 | AC | 1,661 ms
84,224 KB |
testcase_32 | AC | 477 ms
77,568 KB |
testcase_33 | AC | 482 ms
77,568 KB |
testcase_34 | AC | 536 ms
79,984 KB |
testcase_35 | AC | 646 ms
80,416 KB |
testcase_36 | AC | 38 ms
53,504 KB |
testcase_37 | AC | 67 ms
73,856 KB |
testcase_38 | AC | 523 ms
77,428 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 46 ms
64,512 KB |
testcase_45 | AC | 43 ms
62,080 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 161 ms
76,176 KB |
testcase_50 | AC | 164 ms
76,852 KB |
testcase_51 | AC | 165 ms
76,832 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | AC | 43 ms
61,952 KB |
testcase_57 | WA | - |
testcase_58 | AC | 43 ms
53,376 KB |
testcase_59 | WA | - |
testcase_60 | AC | 37 ms
52,608 KB |
testcase_61 | WA | - |
ソースコード
class Matrix(): mod=10**9+7 def set_mod(m): Matrix.mod=m def __init__(self,L): self.row=len(L) self.column=len(L[0]) self._matrix=L for i in range(self.row): for j in range(self.column): self._matrix[i][j]%=Matrix.mod def __getitem__(self,item): if type(item)==int: raise IndexError("you must specific row and column") elif len(item)!=2: raise IndexError("you must specific row and column") i,j=item return self._matrix[i][j] def __setitem__(self,item,val): if type(item)==int: raise IndexError("you must specific row and column") elif len(item)!=2: raise IndexError("you must specific row and column") i,j=item self._matrix[i][j]=val def __add__(self,other): if (self.row,self.column)!=(other.row,other.column): raise SizeError("sizes of matrixes are different") res=[[0 for j in range(self.column)] for i in range(self.row)] for i in range(self.row): for j in range(self.column): res[i][j]=self._matrix[i][j]+other._matrix[i][j] res[i][j]%=Matrix.mod return Matrix(res) def __sub__(self,other): if (self.row,self.column)!=(other.row,other.column): raise SizeError("sizes of matrixes are different") res=[[0 for j in range(self.column)] for i in range(self.row)] for i in range(self.row): for j in range(self.column): res[i][j]=self._matrix[i][j]-other._matrix[i][j] res[i][j]%=Matrix.mod return Matrix(res) def __mul__(self,other): if type(other)!=int: if self.column!=other.row: raise SizeError("sizes of matrixes are different") res=[[0 for j in range(other.column)] for i in range(self.row)] for i in range(self.row): for j in range(other.column): temp=0 for k in range(self.column): temp+=self._matrix[i][k]*other._matrix[k][j] res[i][j]=temp%Matrix.mod return Matrix(res) else: n=other res=[[(n*self._matrix[i][j])%Matrix.mod for j in range(self.column)] for i in range(self.row)] return Matrix(res) def __pow__(self,m): if self.column!=self.row: raise MatrixPowError("the size of row must be the same as that of column") n=self.row res=Matrix([[int(i==j) for i in range(n)] for j in range(n)]) while m: if m%2==1: res=res*self self=self*self m//=2 return res def __str__(self): res=[] for i in range(self.row): for j in range(self.column): res.append(str(self._matrix[i][j])) res.append(" ") res.append("\n") res=res[:len(res)-1] return "".join(res) N,M,T = map(int,input().split()) A = [[0 for j in range(N)] for i in range(N)] for i in range(M): a,b = map(int,input().split()) if not A[a][b]: A[a][b] = 1 A = Matrix(A) A = A**T B = [[1]] + [[0]] * (N-1) B = Matrix(B) A = A*B res = 0 for i in range(N): if A[i,0]: res += 1 print(res)