結果
問題 | No.621 3 x N グリッド上のドミノの置き方の数 |
ユーザー | しらっ亭 |
提出日時 | 2017-12-08 02:22:09 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,055 bytes |
コンパイル時間 | 548 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 29,348 KB |
最終ジャッジ日時 | 2024-11-29 05:41:56 |
合計ジャッジ時間 | 195,871 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 158 ms
22,400 KB |
testcase_01 | AC | 343 ms
18,080 KB |
testcase_02 | AC | 118 ms
22,400 KB |
testcase_03 | AC | 160 ms
18,084 KB |
testcase_04 | AC | 200 ms
18,212 KB |
testcase_05 | AC | 203 ms
18,084 KB |
testcase_06 | AC | 242 ms
18,212 KB |
testcase_07 | AC | 243 ms
22,272 KB |
testcase_08 | AC | 300 ms
18,212 KB |
testcase_09 | AC | 250 ms
22,528 KB |
testcase_10 | AC | 291 ms
18,212 KB |
testcase_11 | AC | 293 ms
22,528 KB |
testcase_12 | AC | 525 ms
22,400 KB |
testcase_13 | AC | 629 ms
18,212 KB |
testcase_14 | AC | 950 ms
18,080 KB |
testcase_15 | AC | 1,266 ms
22,400 KB |
testcase_16 | AC | 1,461 ms
18,084 KB |
testcase_17 | AC | 1,505 ms
22,400 KB |
testcase_18 | AC | 1,972 ms
18,216 KB |
testcase_19 | AC | 2,026 ms
18,080 KB |
testcase_20 | AC | 2,322 ms
18,208 KB |
testcase_21 | AC | 2,402 ms
18,340 KB |
testcase_22 | AC | 2,834 ms
18,080 KB |
testcase_23 | AC | 2,919 ms
22,528 KB |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | TLE | - |
testcase_36 | TLE | - |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | TLE | - |
testcase_40 | TLE | - |
testcase_41 | TLE | - |
testcase_42 | TLE | - |
testcase_43 | TLE | - |
testcase_44 | TLE | - |
testcase_45 | TLE | - |
testcase_46 | TLE | - |
testcase_47 | TLE | - |
testcase_48 | TLE | - |
testcase_49 | TLE | - |
testcase_50 | TLE | - |
testcase_51 | TLE | - |
testcase_52 | TLE | - |
testcase_53 | TLE | - |
testcase_54 | TLE | - |
testcase_55 | TLE | - |
testcase_56 | TLE | - |
testcase_57 | TLE | - |
testcase_58 | TLE | - |
testcase_59 | TLE | - |
testcase_60 | TLE | - |
testcase_61 | TLE | - |
testcase_62 | TLE | - |
testcase_63 | AC | 2,880 ms
11,392 KB |
testcase_64 | AC | 2,918 ms
11,264 KB |
testcase_65 | AC | 2,921 ms
11,264 KB |
testcase_66 | AC | 2,970 ms
11,264 KB |
testcase_67 | AC | 2,919 ms
29,348 KB |
ソースコード
mod = 10 ** 9 + 7 def mat_mul(l, r): ret = [[0] * 64 for _ in range(64)] for i in range(64): for k in range(64): for j in range(64): ret[i][j] += l[i][k] * r[k][j] % mod ret[i][j] %= mod return ret def mat_pow(A, m): B = [[0] * 64 for _ in range(64)] for i in range(64): B[i][i] = 1 while m: if m & 1: B = mat_mul(B, A) A = mat_mul(A, A) m >>= 1 return B def solve(n): mat = [[0] * 64 for _ in range(64)] b3 = 8 for i in range(b3): i0 = (i & 1) != 0 i1 = (i & 2) != 0 i2 = (i & 4) != 0 for j in range(b3): j0 = (j & 1) != 0 j1 = (j & 2) != 0 j2 = (j & 4) != 0 fr = (j << 3) | i for p0 in range(2): if i0 and p0: continue if not j0 and not p0: continue for p1 in range(2): if i1 and p1: continue if not j1 and not p1: continue for p2 in range(2): if i2 and p2: continue if not j2 and not p2: continue if (i0 | p0) == 0 and (i1 | p1) == 0: continue if (i2 | p2) == 0 and (i1 | p1) == 0: continue y = (p2 << 2) + (p1 << 1) + p0 x = y | i to = (x << 3) | y mat[fr][to] += 1 if not i0 and not i1: if i2: x = 3 + (1 << 2) y = 0 + (0 << 2) to = (x << 3) | y mat[fr][to] += 1 elif j2: for p2 in range(2): x = 3 + (p2 << 2) y = 0 + (p2 << 2) to = (x << 3) | y mat[fr][to] += 1 else: x = 3 + (1 << 2) y = 0 + (1 << 2) to = (x << 3) | y mat[fr][to] += 1 if not i1 and not i2: if i0: x = 6 + (1 << 0) y = 0 + (0 << 0) to = (x << 3) | y mat[fr][to] += 1 elif j0: for p2 in range(2): x = 6 + (p2 << 0) y = 0 + (p2 << 0) to = (x << 3) | y mat[fr][to] += 1 else: x = 6 + (1 << 0) y = 0 + (1 << 0) to = (x << 3) | y mat[fr][to] += 1 mat = mat_pow(mat, n) ans = 0 for j in range(2, b3): if j == 4: continue fr = j << 3 ans += mat[0b111000][fr] return ans % mod print(solve(int(input())))