結果

問題 No.2445 奇行列式
ユーザー ShirotsumeShirotsume
提出日時 2023-06-02 19:41:08
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,058 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 171,576 KB
最終ジャッジ日時 2023-09-21 20:31:48
合計ジャッジ時間 9,886 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
74,828 KB
testcase_01 AC 115 ms
74,728 KB
testcase_02 AC 114 ms
74,764 KB
testcase_03 AC 118 ms
74,548 KB
testcase_04 AC 115 ms
74,296 KB
testcase_05 AC 114 ms
74,604 KB
testcase_06 AC 115 ms
74,792 KB
testcase_07 AC 126 ms
79,660 KB
testcase_08 AC 130 ms
79,424 KB
testcase_09 AC 114 ms
74,944 KB
testcase_10 AC 115 ms
74,764 KB
testcase_11 AC 235 ms
84,380 KB
testcase_12 AC 614 ms
99,080 KB
testcase_13 AC 2,351 ms
171,576 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = [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])
0