結果

問題 No.2445 奇行列式
ユーザー tassei903tassei903
提出日時 2023-08-25 22:12:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,450 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 272,492 KB
最終ジャッジ日時 2023-08-25 22:13:10
合計ジャッジ時間 9,147 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,316 KB
testcase_01 AC 58 ms
71,484 KB
testcase_02 AC 59 ms
71,228 KB
testcase_03 AC 61 ms
71,536 KB
testcase_04 AC 59 ms
71,412 KB
testcase_05 AC 60 ms
71,516 KB
testcase_06 AC 61 ms
71,468 KB
testcase_07 AC 68 ms
76,820 KB
testcase_08 AC 76 ms
76,916 KB
testcase_09 AC 60 ms
71,312 KB
testcase_10 AC 56 ms
71,372 KB
testcase_11 AC 149 ms
80,724 KB
testcase_12 AC 398 ms
94,516 KB
testcase_13 AC 1,574 ms
163,104 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 AC 583 ms
93,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
def popcnt3(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c
n, mod = na()
a = [na() for i in range(n)]
dp0 = [0] * (1<<n)
dp1 = [0] * (1<<n)
dp0[0] = 1
t = [((1 << n) - (1 << j)) for j in range(n)]
for i in range(1<<n):
    pc = popcnt3(i)
    for j in range(n):
        if i >> j & 1:
            continue
        c = popcnt3(i & t[j])
        if c % 2:
            dp0[i | (1<<j)] += dp1[i] * a[pc][j]
            dp0[i | (1<<j)] %= mod
            dp1[i | (1<<j)] += dp0[i] * a[pc][j]
            dp1[i | (1<<j)] %= mod
        else:
            dp0[i | (1<<j)] += dp0[i] * a[pc][j]
            dp0[i | (1<<j)] %= mod
            dp1[i | (1<<j)] += dp1[i] * a[pc][j]
            dp1[i | (1<<j)] %= mod
#print(dp0, dp1)
print(dp1[-1])
0