結果
問題 | No.1112 冥界の音楽 |
ユーザー | brthyyjp |
提出日時 | 2020-07-10 23:00:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,770 bytes |
コンパイル時間 | 1,475 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 87,680 KB |
最終ジャッジ日時 | 2024-10-11 15:14:09 |
合計ジャッジ時間 | 7,908 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
65,280 KB |
testcase_01 | AC | 40 ms
52,736 KB |
testcase_02 | AC | 37 ms
52,224 KB |
testcase_03 | AC | 37 ms
52,224 KB |
testcase_04 | AC | 38 ms
52,608 KB |
testcase_05 | AC | 42 ms
58,368 KB |
testcase_06 | AC | 131 ms
69,120 KB |
testcase_07 | AC | 38 ms
52,480 KB |
testcase_08 | AC | 41 ms
52,224 KB |
testcase_09 | AC | 52 ms
61,696 KB |
testcase_10 | AC | 38 ms
52,224 KB |
testcase_11 | AC | 60 ms
63,872 KB |
testcase_12 | AC | 38 ms
52,096 KB |
testcase_13 | AC | 39 ms
52,864 KB |
testcase_14 | AC | 395 ms
76,544 KB |
testcase_15 | AC | 90 ms
68,736 KB |
testcase_16 | AC | 39 ms
52,480 KB |
testcase_17 | AC | 138 ms
73,856 KB |
testcase_18 | AC | 133 ms
73,272 KB |
testcase_19 | AC | 39 ms
52,352 KB |
testcase_20 | AC | 63 ms
64,640 KB |
testcase_21 | AC | 297 ms
76,288 KB |
testcase_22 | AC | 460 ms
76,160 KB |
testcase_23 | AC | 118 ms
70,784 KB |
testcase_24 | AC | 38 ms
52,352 KB |
testcase_25 | AC | 39 ms
52,608 KB |
testcase_26 | AC | 44 ms
60,032 KB |
testcase_27 | AC | 49 ms
61,952 KB |
testcase_28 | AC | 65 ms
70,016 KB |
testcase_29 | AC | 38 ms
52,992 KB |
testcase_30 | AC | 282 ms
76,288 KB |
testcase_31 | AC | 52 ms
63,104 KB |
testcase_32 | AC | 309 ms
75,960 KB |
testcase_33 | AC | 48 ms
61,696 KB |
testcase_34 | AC | 39 ms
52,736 KB |
testcase_35 | AC | 44 ms
60,160 KB |
testcase_36 | TLE | - |
ソースコード
import sys input = sys.stdin.buffer.readline def main(): k, m, n = map(int, input().split()) #mod =10**9+7 PQR = [] for i in range(m): p, q, r = map(int, input().split()) p, q, r = p-1, q-1, r-1 PQR.append((p, q, r)) if n == 3: ans = 0 for i in range(m): p1, q1, r1 = PQR[i] if p1 == 0 and r1 == 0: ans += 1 print(ans) exit() A = [[0]*m for _ in range(m)] for i in range(m): p1, q1, r1 = PQR[i] for j in range(m): p2, q2, r2 = PQR[j] if q1 == p2 and r1 == q2: A[i][j] = 1 C = [[0]*m for _ in range(m)] for i in range(m): p1, q1, r1 = PQR[i] if p1 != 0: continue for j in range(m): p2, q2, r2 = PQR[j] if q1 == p2 and r1 == q2: C[i][j] = 1 # A*B def mul(a, b): c = [[0]*len(b[0]) for i in range(len(a))] for i in range(len(a)): for k in range(len(b)): for j in range(len(b[0])): c[i][j] = (c[i][j] + a[i][k]*b[k][j])%mod return c #A**n def pow(a, n): b = [[0]*len(a) for i in range(len(a))] for i in range(len(a)): b[i][i] = 1 while n > 0: if n & 1 == 1: b = mul(a, b) a = mul(a, a) n = n>>1 return b #print(C) B = pow(A, n-4) B = mul(C, B) #print(B) ans = 0 for i in range(m): p1, q1, r1 = PQR[i] if r1 == 0: for j in range(m): ans += B[j][i] #ans %= mod print(ans%mod) if __name__ == '__main__': mod =10**9+7 main()