結果

問題 No.1937 Various Tournament
ユーザー 沙耶花沙耶花
提出日時 2022-05-13 22:26:42
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 1,269 ms / 2,000 ms
コード長 1,576 bytes
コンパイル時間 4,188 ms
使用メモリ 8,364 KB
最終ジャッジ日時 2023-02-21 15:26:08
合計ジャッジ時間 37,121 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
6,252 KB
testcase_01 AC 333 ms
6,208 KB
testcase_02 AC 905 ms
6,200 KB
testcase_03 AC 1,025 ms
6,168 KB
testcase_04 AC 909 ms
6,184 KB
testcase_05 AC 1 ms
6,276 KB
testcase_06 AC 1,037 ms
6,252 KB
testcase_07 AC 1,048 ms
6,276 KB
testcase_08 AC 2 ms
6,252 KB
testcase_09 AC 1,269 ms
6,280 KB
testcase_10 AC 2 ms
6,248 KB
testcase_11 AC 791 ms
6,264 KB
testcase_12 AC 1,056 ms
6,212 KB
testcase_13 AC 953 ms
6,212 KB
testcase_14 AC 931 ms
6,320 KB
testcase_15 AC 1,131 ms
7,584 KB
testcase_16 AC 1,028 ms
7,672 KB
testcase_17 AC 984 ms
8,300 KB
testcase_18 AC 1,087 ms
8,208 KB
testcase_19 AC 1,026 ms
8,248 KB
testcase_20 AC 1 ms
8,248 KB
testcase_21 AC 1 ms
8,296 KB
testcase_22 AC 812 ms
8,236 KB
testcase_23 AC 1,028 ms
7,720 KB
testcase_24 AC 909 ms
7,568 KB
testcase_25 AC 2 ms
7,688 KB
testcase_26 AC 891 ms
8,364 KB
testcase_27 AC 2 ms
8,316 KB
testcase_28 AC 779 ms
8,216 KB
testcase_29 AC 2 ms
7,652 KB
testcase_30 AC 1,065 ms
8,312 KB
testcase_31 AC 974 ms
7,592 KB
testcase_32 AC 1,155 ms
7,580 KB
testcase_33 AC 1,191 ms
7,600 KB
testcase_34 AC 981 ms
8,324 KB
testcase_35 AC 1,117 ms
8,240 KB
testcase_36 AC 1,020 ms
8,296 KB
testcase_37 AC 2 ms
8,208 KB
testcase_38 AC 1 ms
7,580 KB
testcase_39 AC 938 ms
8,304 KB
testcase_40 AC 2 ms
8,220 KB
testcase_41 AC 2 ms
8,236 KB
testcase_42 AC 1,069 ms
8,308 KB
testcase_43 AC 2 ms
7,600 KB
testcase_44 AC 2 ms
8,312 KB
testcase_45 AC 1,066 ms
8,316 KB
testcase_46 AC 2 ms
7,672 KB
testcase_47 AC 2 ms
7,604 KB
testcase_48 AC 2 ms
8,300 KB
testcase_49 AC 2 ms
7,584 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