結果
問題 | No.1340 おーじ君をさがせ |
ユーザー | chineristAC |
提出日時 | 2021-01-15 21:49:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,423 bytes |
コンパイル時間 | 126 ms |
コンパイル使用メモリ | 82,784 KB |
実行使用メモリ | 81,152 KB |
最終ジャッジ日時 | 2024-05-05 02:39:47 |
合計ジャッジ時間 | 13,292 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,608 KB |
testcase_01 | AC | 37 ms
52,864 KB |
testcase_02 | AC | 35 ms
52,736 KB |
testcase_03 | AC | 35 ms
52,864 KB |
testcase_04 | AC | 37 ms
52,864 KB |
testcase_05 | AC | 35 ms
52,608 KB |
testcase_06 | AC | 46 ms
52,736 KB |
testcase_07 | AC | 36 ms
52,992 KB |
testcase_08 | AC | 35 ms
52,736 KB |
testcase_09 | AC | 34 ms
53,120 KB |
testcase_10 | AC | 56 ms
67,200 KB |
testcase_11 | AC | 120 ms
76,032 KB |
testcase_12 | AC | 86 ms
76,288 KB |
testcase_13 | AC | 207 ms
76,800 KB |
testcase_14 | AC | 171 ms
76,544 KB |
testcase_15 | AC | 149 ms
76,416 KB |
testcase_16 | AC | 80 ms
73,600 KB |
testcase_17 | AC | 92 ms
76,160 KB |
testcase_18 | AC | 116 ms
76,416 KB |
testcase_19 | AC | 55 ms
68,224 KB |
testcase_20 | AC | 53 ms
66,432 KB |
testcase_21 | AC | 166 ms
76,928 KB |
testcase_22 | AC | 1,237 ms
81,152 KB |
testcase_23 | AC | 304 ms
76,416 KB |
testcase_24 | TLE | - |
testcase_25 | AC | 85 ms
76,672 KB |
testcase_26 | AC | 82 ms
76,160 KB |
testcase_27 | AC | 79 ms
76,928 KB |
testcase_28 | AC | 91 ms
76,544 KB |
testcase_29 | AC | 73 ms
76,384 KB |
testcase_30 | AC | 177 ms
76,544 KB |
testcase_31 | AC | 501 ms
77,952 KB |
testcase_32 | AC | 334 ms
77,824 KB |
testcase_33 | AC | 343 ms
77,556 KB |
testcase_34 | AC | 521 ms
77,312 KB |
testcase_35 | AC | 634 ms
77,312 KB |
testcase_36 | AC | 36 ms
53,248 KB |
testcase_37 | AC | 61 ms
73,344 KB |
testcase_38 | AC | 346 ms
77,312 KB |
testcase_39 | AC | 188 ms
77,268 KB |
testcase_40 | AC | 171 ms
76,936 KB |
testcase_41 | AC | 175 ms
77,056 KB |
testcase_42 | AC | 40 ms
60,288 KB |
testcase_43 | AC | 41 ms
61,056 KB |
testcase_44 | AC | 45 ms
63,744 KB |
testcase_45 | AC | 42 ms
61,568 KB |
testcase_46 | AC | 230 ms
76,800 KB |
testcase_47 | AC | 243 ms
77,056 KB |
testcase_48 | AC | 272 ms
76,672 KB |
testcase_49 | AC | 153 ms
76,652 KB |
testcase_50 | AC | 162 ms
76,588 KB |
testcase_51 | AC | 171 ms
76,544 KB |
testcase_52 | AC | 194 ms
76,800 KB |
testcase_53 | AC | 177 ms
76,288 KB |
testcase_54 | AC | 180 ms
76,416 KB |
testcase_55 | AC | 333 ms
77,600 KB |
testcase_56 | AC | 44 ms
61,312 KB |
testcase_57 | AC | 43 ms
61,440 KB |
testcase_58 | AC | 36 ms
52,608 KB |
testcase_59 | AC | 98 ms
76,328 KB |
testcase_60 | AC | 37 ms
53,120 KB |
testcase_61 | AC | 97 ms
76,032 KB |
ソースコード
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): if self._matrix[i][k] and other._matrix[k][j]: temp = 1 res[i][j]=temp 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[b][a]: A[b][a] = 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)