結果

問題 No.1937 Various Tournament
ユーザー 沙耶花沙耶花
提出日時 2022-05-13 22:26:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,258 ms / 2,000 ms
コード長 1,576 bytes
コンパイル時間 4,633 ms
コンパイル使用メモリ 265,148 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 07:55:34
合計ジャッジ時間 36,703 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 332 ms
4,376 KB
testcase_02 AC 900 ms
4,380 KB
testcase_03 AC 1,017 ms
4,376 KB
testcase_04 AC 904 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1,036 ms
4,384 KB
testcase_07 AC 1,045 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1,258 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 789 ms
4,376 KB
testcase_12 AC 1,052 ms
4,380 KB
testcase_13 AC 951 ms
4,376 KB
testcase_14 AC 928 ms
4,376 KB
testcase_15 AC 1,115 ms
4,380 KB
testcase_16 AC 1,025 ms
4,380 KB
testcase_17 AC 982 ms
4,380 KB
testcase_18 AC 1,082 ms
4,380 KB
testcase_19 AC 1,023 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 809 ms
4,376 KB
testcase_23 AC 1,023 ms
4,376 KB
testcase_24 AC 912 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 890 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 780 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1,062 ms
4,380 KB
testcase_31 AC 972 ms
4,376 KB
testcase_32 AC 1,152 ms
4,376 KB
testcase_33 AC 1,180 ms
4,376 KB
testcase_34 AC 982 ms
4,376 KB
testcase_35 AC 1,115 ms
4,380 KB
testcase_36 AC 1,019 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 934 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1,062 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1,063 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n;
vector<string> s;



int main(){
	
	cin>>n;
	s.resize(n,"");
	
	rep(i,n){
		rep(j,n){
			int t;
			cin>>t;
			s[i] += '0'+t;
		}
	}
	
	/*
	n = 16;
	s.resize(16,string(16,'b'));
	rep(i,n){
		rep(j,n){
			if(i<j)s[i][j] = '1';
			else s[i][j] = '0';
		}
	}
	*/
	
	vector<long long> ans(n,0);
	vector<long long> ddp,ndp;
	rep(i,n){
		vector<long long> dp(1<<n,0);
		dp[1<<i] = 1;
		long long c = 1LL;
		while(c!=n){
			rep(j,dp.size()){
				if(__builtin_popcount(j)!=c||dp[j]==0)continue;
				vector<int> x,y;
				rep(k,n){
					if((j>>k)&1)x.push_back(k);
					else y.push_back(k);
				}
				ddp.assign(1<<y.size(),0);
				ddp[0] = 1;
				rep(k,x.size()){
					ndp.assign(1<<y.size(),0);
					rep(l,ddp.size()){
						if(ddp[l]==0)continue;
						rep(ll,y.size()){
							if((l>>ll)&1)continue;
							if(s[x[k]][y[ll]]=='0')continue;
							ndp[l | (1<<ll)] += ddp[l];
						}
					}
					swap(ddp,ndp);
				}
				rep(k,ddp.size()){
					if(ddp[k]==0)continue;
					int T  =0;
					rep(l,y.size()){
						if((k>>l)&1)T |= 1<<y[l];
					}
					//cout<<j<<','<<T<<endl;
					dp[T|j] += dp[j] * ddp[k];
				}
				//dp[j] = 0;
			}
			c*=2;
			/*
			rep(j,dp.size()){
				cout<<dp[j]<<',';
			}
			cout<<endl;
			*/
		}
		ans[i] += dp.back();
		//ans[i] += dp.back();
	}
	
	rep(i,n)ans[i] *= 1LL<<(n-1);
	
	rep(i,n){
		cout<<ans[i]<<endl;
	}
	
    return 0;
}
0