結果

問題 No.2445 奇行列式
ユーザー shobonvipshobonvip
提出日時 2023-08-26 01:45:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,702 bytes
コンパイル時間 4,356 ms
コンパイル使用メモリ 264,604 KB
実行使用メモリ 11,696 KB
最終ジャッジ日時 2023-08-26 01:45:18
合計ジャッジ時間 7,228 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	int n; cin >> n;
	int b; cin >> b;
	mint::set_mod(b);
	vector<vector<mint>> a(n, vector<mint>(n));
	rep(i,0,n){
		rep(j,0,n){
			int x; cin >> x;
			a[i][j] = x;
		}
	}
	vector<mint> odp(1<<n);
	vector<mint> edp(1<<n);
	edp[0] = 1;
	rep(num,1,n+1){
		rep(i,0,1<<n){
			if (__popcount(i) != num) continue;
			int cnt = 0;
			rrep(j,0,n){
				if (i >> j & 1){
					if (cnt % 2 == 0){
						edp[i] += edp[i ^ (1<<j)] * a[num-1][j];
						odp[i] += odp[i ^ (1<<j)] * a[num-1][j];
					}else{
						edp[i] += odp[i ^ (1<<j)] * a[num-1][j];
						odp[i] += edp[i ^ (1<<j)] * a[num-1][j];
					}
					cnt++;
				}
			}
		}
	}
	cout << odp[(1<<n)-1].val() << '\n';
}

0