結果

問題 No.2435 Order All Company
ユーザー cho435cho435
提出日時 2023-08-26 01:49:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,141 bytes
コンパイル時間 5,511 ms
コンパイル使用メモリ 267,688 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-26 01:50:03
合計ジャッジ時間 7,401 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 45 ms
4,380 KB
testcase_06 AC 45 ms
4,376 KB
testcase_07 AC 26 ms
4,376 KB
testcase_08 AC 44 ms
4,380 KB
testcase_09 AC 45 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 34 ms
4,380 KB
testcase_15 AC 38 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 45 ms
4,384 KB
testcase_18 WA -
testcase_19 AC 28 ms
4,376 KB
testcase_20 AC 27 ms
4,380 KB
testcase_21 AC 32 ms
4,376 KB
testcase_22 AC 34 ms
4,376 KB
testcase_23 AC 21 ms
4,380 KB
testcase_24 AC 33 ms
4,380 KB
testcase_25 AC 33 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 33 ms
4,380 KB
testcase_28 AC 28 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 35 ms
4,384 KB
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 WA -
testcase_34 AC 3 ms
4,376 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;


int n;
using mat=vector<vector<mint>>;

void tri(mat &a){
	rep(i,n-1){
		if(a.at(i).at(i)==0){
			for(int j=i+1;j<n;j++){
				if(a.at(j).at(i)!=0){
					swap(a.at(i),a.at(j));
					rep(k,n) a.at(j).at(k)*=-1;
					break;
				}
			}
			if(a.at(i).at(i)==0) continue;
		}
		for(int j=i+1;j<n;j++){
			mint p=a.at(j).at(i)/a.at(i).at(i);
			rep(k,n) a.at(j).at(k)-=a.at(i).at(k)*p;
		}
	}
}

int main(){
	int k;
	cin>>n>>k;
	vector<mat> g(k,mat(n,vector<mint>(n,0)));
	rep(i,k){
		int t;
		cin>>t;
		rep(lp,t){
			int a,b;
			cin>>a>>b;
			a--; b--;
			g.at(i).at(a).at(a)++;
			g.at(i).at(b).at(b)++;
			g.at(i).at(a).at(b)--;
			g.at(i).at(b).at(a)--;
		}
	}
	mint ans=0;
	rep(bit,(1<<k)){
		mat ad(n,vector<mint>(n,0));
		rep(i,k){
			if(bit>>i&1){
				rep(a,n) rep(b,n) ad.at(a).at(b)+=g.at(i).at(a).at(b);
			}
		}
		tri(ad);
		mint tmp=1;
		rep(i,n-1) tmp*=ad.at(i).at(i);
		if(__builtin_popcount(bit)%2) ans+=tmp;
		else ans-=tmp;
	}
	cout<<ans.val()<<endl;
}
0