結果

問題 No.1937 Various Tournament
ユーザー 沙耶花
提出日時 2022-05-13 21:54:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,125 bytes
コンパイル時間 4,670 ms
コンパイル使用メモリ 264,888 KB
最終ジャッジ日時 2025-01-29 06:58:14
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 TLE * 31
権限があれば一括ダウンロードができます

ソースコード

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;

map<vector<int>,long long> mp;

void dfs(vector<int> a,vector<int> b,long long num){
	if(a.size()==0){
		//cout<<b[0]<<endl;
		mp[b] += num;
		return;
	}
	int x = a.back();
	a.pop_back();
	rep(i,a.size()){
		int y = a.back();
		a.pop_back();
		if(s[x][y]=='1')b.push_back(x);
		else b.push_back(y);
		dfs(a,b,num);
		b.pop_back();
		a.insert(a.begin(),y);
	}
}

int main(){
	
	cin>>n;
	s.resize(n,"");
	rep(i,n){
		rep(j,n){
			int t;
			cin>>t;
			s[i] += '0'+t;
		}
	}
	//mp[
	//ans.resize(n,0);
	vector<int> a(n);
	rep(i,n)a[i] = i;
	mp[a] ++;
	int nn = n;
	while(n!=1){
		vector<int> b;
		map<vector<int>,long long> nmp = mp;
		mp.clear();
		for(auto x:nmp){
			dfs(x.first,b,x.second);
		}
		n>>=1;
	}
	n = nn;
	vector<long long> ans(n,0);
	for(auto x:mp){
		ans[x.first[0]] += x.second;
	}
	
	rep(i,n)ans[i] *= 1LL<<(n-1);
	
	rep(i,n){
		cout<<ans[i]<<endl;
	}
	
    return 0;
}
0