結果

問題 No.2445 奇行列式
ユーザー tassei903tassei903
提出日時 2023-08-25 22:10:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,156 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 262,872 KB
最終ジャッジ日時 2023-08-25 22:10:44
合計ジャッジ時間 10,775 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
262,872 KB
testcase_01 AC 70 ms
71,344 KB
testcase_02 AC 71 ms
71,244 KB
testcase_03 AC 78 ms
71,244 KB
testcase_04 AC 71 ms
71,488 KB
testcase_05 AC 73 ms
76,116 KB
testcase_06 AC 79 ms
76,612 KB
testcase_07 AC 87 ms
76,724 KB
testcase_08 AC 96 ms
76,744 KB
testcase_09 AC 69 ms
71,208 KB
testcase_10 AC 70 ms
71,288 KB
testcase_11 AC 242 ms
80,444 KB
testcase_12 AC 792 ms
94,624 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

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")
#######################################################################
n, mod = na()
a = [na() for i in range(n)]
dp0 = [0] * (1<<n)
dp1 = [0] * (1<<n)
dp0[0] = 1

for i in range(1<<n):
    for j in range(n):
        if i >> j & 1:
            continue
        c = 0
        for k in range(j+1, n):
            if i >> k & 1:
                c += 1
        pc = 0
        for k in range(n):
            if i >> k & 1:
                pc += 1
        #print(bin(i), j, c, pc)
        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