結果
問題 | No.1112 冥界の音楽 |
ユーザー | brthyyjp |
提出日時 | 2020-07-10 22:56:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,755 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,016 KB |
実行使用メモリ | 87,552 KB |
最終ジャッジ日時 | 2024-10-11 05:01:19 |
合計ジャッジ時間 | 8,109 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
65,024 KB |
testcase_01 | AC | 37 ms
52,480 KB |
testcase_02 | AC | 38 ms
52,224 KB |
testcase_03 | AC | 38 ms
52,736 KB |
testcase_04 | AC | 40 ms
52,736 KB |
testcase_05 | AC | 42 ms
58,752 KB |
testcase_06 | AC | 124 ms
69,120 KB |
testcase_07 | AC | 38 ms
52,224 KB |
testcase_08 | AC | 38 ms
52,608 KB |
testcase_09 | AC | 48 ms
61,440 KB |
testcase_10 | AC | 38 ms
52,352 KB |
testcase_11 | AC | 59 ms
63,744 KB |
testcase_12 | AC | 39 ms
52,352 KB |
testcase_13 | AC | 38 ms
52,992 KB |
testcase_14 | AC | 394 ms
76,488 KB |
testcase_15 | AC | 90 ms
69,504 KB |
testcase_16 | AC | 38 ms
52,608 KB |
testcase_17 | AC | 135 ms
73,984 KB |
testcase_18 | AC | 130 ms
73,216 KB |
testcase_19 | AC | 38 ms
52,224 KB |
testcase_20 | AC | 62 ms
64,384 KB |
testcase_21 | AC | 295 ms
76,288 KB |
testcase_22 | AC | 447 ms
76,396 KB |
testcase_23 | AC | 116 ms
70,656 KB |
testcase_24 | AC | 38 ms
52,992 KB |
testcase_25 | AC | 38 ms
52,608 KB |
testcase_26 | AC | 45 ms
60,160 KB |
testcase_27 | AC | 49 ms
61,568 KB |
testcase_28 | AC | 61 ms
70,272 KB |
testcase_29 | AC | 39 ms
52,608 KB |
testcase_30 | AC | 281 ms
76,140 KB |
testcase_31 | AC | 51 ms
63,232 KB |
testcase_32 | AC | 305 ms
76,160 KB |
testcase_33 | AC | 48 ms
61,824 KB |
testcase_34 | AC | 40 ms
52,736 KB |
testcase_35 | AC | 46 ms
60,544 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 = mul(C, pow(A, n-4)) #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) if __name__ == '__main__': mod =10**9+7 main()