結果
問題 | No.1112 冥界の音楽 |
ユーザー | brthyyjp |
提出日時 | 2020-10-13 05:36:01 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,399 bytes |
コンパイル時間 | 357 ms |
コンパイル使用メモリ | 82,212 KB |
実行使用メモリ | 89,112 KB |
最終ジャッジ日時 | 2024-07-20 18:21:07 |
合計ジャッジ時間 | 8,146 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
65,664 KB |
testcase_01 | AC | 41 ms
52,480 KB |
testcase_02 | AC | 40 ms
52,480 KB |
testcase_03 | AC | 40 ms
52,352 KB |
testcase_04 | AC | 41 ms
52,480 KB |
testcase_05 | AC | 44 ms
58,368 KB |
testcase_06 | AC | 135 ms
69,504 KB |
testcase_07 | AC | 41 ms
52,352 KB |
testcase_08 | AC | 40 ms
52,096 KB |
testcase_09 | AC | 54 ms
61,312 KB |
testcase_10 | AC | 41 ms
52,480 KB |
testcase_11 | AC | 65 ms
63,872 KB |
testcase_12 | AC | 40 ms
52,480 KB |
testcase_13 | AC | 43 ms
53,376 KB |
testcase_14 | AC | 402 ms
76,288 KB |
testcase_15 | AC | 93 ms
68,736 KB |
testcase_16 | AC | 39 ms
52,480 KB |
testcase_17 | AC | 140 ms
74,440 KB |
testcase_18 | AC | 135 ms
73,344 KB |
testcase_19 | AC | 39 ms
52,480 KB |
testcase_20 | AC | 65 ms
64,640 KB |
testcase_21 | AC | 304 ms
76,272 KB |
testcase_22 | AC | 457 ms
76,288 KB |
testcase_23 | AC | 122 ms
71,424 KB |
testcase_24 | AC | 40 ms
52,480 KB |
testcase_25 | AC | 41 ms
52,736 KB |
testcase_26 | AC | 47 ms
60,160 KB |
testcase_27 | AC | 50 ms
61,184 KB |
testcase_28 | AC | 62 ms
70,144 KB |
testcase_29 | AC | 40 ms
52,224 KB |
testcase_30 | AC | 284 ms
76,364 KB |
testcase_31 | AC | 53 ms
63,488 KB |
testcase_32 | AC | 312 ms
76,032 KB |
testcase_33 | AC | 50 ms
61,696 KB |
testcase_34 | AC | 40 ms
52,864 KB |
testcase_35 | AC | 47 ms
59,776 KB |
testcase_36 | TLE | - |
ソースコード
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%mod)