結果
問題 | No.1112 冥界の音楽 |
ユーザー | mkawa2 |
提出日時 | 2020-07-10 22:33:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,467 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 82,200 KB |
実行使用メモリ | 92,756 KB |
最終ジャッジ日時 | 2024-10-11 09:55:01 |
合計ジャッジ時間 | 14,732 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
68,092 KB |
testcase_01 | AC | 38 ms
52,780 KB |
testcase_02 | AC | 38 ms
53,440 KB |
testcase_03 | WA | - |
testcase_04 | AC | 38 ms
53,208 KB |
testcase_05 | AC | 39 ms
54,040 KB |
testcase_06 | AC | 259 ms
76,940 KB |
testcase_07 | AC | 38 ms
53,164 KB |
testcase_08 | WA | - |
testcase_09 | AC | 78 ms
76,052 KB |
testcase_10 | AC | 39 ms
53,928 KB |
testcase_11 | AC | 92 ms
75,936 KB |
testcase_12 | AC | 38 ms
53,136 KB |
testcase_13 | AC | 39 ms
53,480 KB |
testcase_14 | AC | 1,622 ms
81,780 KB |
testcase_15 | AC | 230 ms
77,108 KB |
testcase_16 | AC | 37 ms
52,744 KB |
testcase_17 | AC | 440 ms
77,580 KB |
testcase_18 | AC | 429 ms
77,524 KB |
testcase_19 | AC | 38 ms
52,552 KB |
testcase_20 | AC | 124 ms
76,448 KB |
testcase_21 | AC | 1,207 ms
79,896 KB |
testcase_22 | AC | 1,800 ms
81,732 KB |
testcase_23 | AC | 340 ms
77,644 KB |
testcase_24 | AC | 39 ms
53,816 KB |
testcase_25 | AC | 39 ms
53,412 KB |
testcase_26 | AC | 48 ms
61,388 KB |
testcase_27 | AC | 63 ms
69,248 KB |
testcase_28 | AC | 93 ms
76,284 KB |
testcase_29 | AC | 39 ms
53,480 KB |
testcase_30 | AC | 1,143 ms
80,880 KB |
testcase_31 | AC | 85 ms
76,156 KB |
testcase_32 | AC | 1,203 ms
81,420 KB |
testcase_33 | AC | 55 ms
66,568 KB |
testcase_34 | AC | 37 ms
53,692 KB |
testcase_35 | AC | 47 ms
61,504 KB |
testcase_36 | TLE | - |
ソースコード
import sys def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] def dot(aa,bb): return [[sum(a*b for a,b in zip(row,col))%md for col in zip(*bb)] for row in aa] def solve(n): if n == 3: ans = 0 for p, q, r in pqr: if p == 1 and q == 1: ans += 1 print(ans) exit() start = [] end = [] to = [[0] * m for _ in range(m)] for i in range(m): if pqr[i][0] == 1: start.append(i) if pqr[i][2] == 1: end.append(i) for j in range(m): if pqr[i][1:] == pqr[j][:2]: to[i][j] = 1 # print(start,end) # print(to) cnt = [[0] * i + [1] + [0] * (m - i - 1) for i in range(m)] n -= 3 while n: if n & 1: cnt = dot(cnt, to) to = dot(to, to) n >>= 1 # print(cnt) ans = 0 for s in start: for e in end: ans += cnt[s][e] ans %= md print(ans) md=10**9+7 k,m,n=MI() pqr=LLI(m) solve(n)