結果
| 問題 |
No.2445 奇行列式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-02 19:42:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 748 ms / 3,000 ms |
| コード長 | 1,078 bytes |
| コンパイル時間 | 479 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 101,632 KB |
| 最終ジャッジ日時 | 2024-12-28 15:45:35 |
| 合計ジャッジ時間 | 7,170 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
n, mod = mi()
A = [[v % mod for v in li()] for _ in range(n)]
ppcnt = [0] * (1 << n)
for i in range(1, 1<<n):
ppcnt[i] = ppcnt[i//2] + i % 2
dpsum = [[0] * (1<<n) for _ in range(2)]
dpsum[0][0] = 1
for bit in range(1<<n):
cnt = ppcnt[bit]
for i in range(n):
if 1 & (bit >> i):
cnt -= 1
if not(1 & (bit >> i)):
if cnt % 2:
dpsum[1][bit | (1 << i)] += dpsum[0][bit] * A[ppcnt[bit]][i]
dpsum[0][bit | (1 << i)] += dpsum[1][bit] * A[ppcnt[bit]][i]
else:
dpsum[1][bit | (1 << i)] += dpsum[1][bit] * A[ppcnt[bit]][i]
dpsum[0][bit | (1 << i)] += dpsum[0][bit] * A[ppcnt[bit]][i]
dpsum[0][bit | (1 << i)] %= mod
dpsum[1][bit | (1 << i)] %= mod
print(dpsum[-1][-1])