結果

問題 No.2445 奇行列式
ユーザー 沙耶花沙耶花
提出日時 2023-08-25 21:47:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 606 ms / 3,000 ms
コード長 748 bytes
コンパイル時間 4,630 ms
コンパイル使用メモリ 263,132 KB
実行使用メモリ 60,552 KB
最終ジャッジ日時 2023-08-25 21:47:13
合計ジャッジ時間 9,486 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 15 ms
5,068 KB
testcase_12 AC 64 ms
10,224 KB
testcase_13 AC 284 ms
31,784 KB
testcase_14 AC 602 ms
60,420 KB
testcase_15 AC 604 ms
60,376 KB
testcase_16 AC 601 ms
60,552 KB
testcase_17 AC 606 ms
60,420 KB
testcase_18 AC 606 ms
60,428 KB
testcase_19 AC 415 ms
60,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001




int main(){
	int N,B,Q;
	cin>>N>>B;
	mint::set_mod(B);
	vector a(N,vector<mint>(N));
	rep(i,N){
		rep(j,N){
			long long t;
			cin>>t;
			a[i][j] = t;
		}
	}
	vector dp(1<<N,vector<mint>(2,0));
	dp[0][0] = 1;
	rep(i,1<<N){
		int ii = __builtin_popcount(i);
		if(ii==N)continue;
		rep(j,2){
			rep(k,N){
				if((i>>k)&1)continue;
				int jj = j;
				for(int l=k+1;l<N;l++)if((i>>l)&1)jj ^= 1;
				dp[i|(1<<k)][jj] += dp[i][j] * a[ii][k];
				
			}
		}
	}
	
	cout<<dp.back()[1].val()<<endl;
	
	return 0;
}
0