結果
| 問題 | No.753 最強王者決定戦 |
| コンテスト | |
| ユーザー |
mugen_1337
|
| 提出日時 | 2021-03-30 09:37:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,320 bytes |
| コンパイル時間 | 3,600 ms |
| コンパイル使用メモリ | 203,776 KB |
| 最終ジャッジ日時 | 2025-01-20 00:50:19 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 4 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 998244353
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
struct IOSetup{
IOSetup(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(12);
}
} iosetup;
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
for(T &x:v)is>>x;
return is;
}
vector<int> enumerate_subset(int bit,bool include_bit_empty=false){
vector<int> ret;
int subset=(bit-1)&bit;
do{
ret.push_back(subset);
subset=(subset-1)&bit;
}while(subset!=0);
if(include_bit_empty){
ret.push_back(0);
if(0!=bit) ret.push_back(bit);
}
return ret;
}
const int n=16;
signed main(){
vector<vector<int>> a(n,vector<int>(n));
cin>>a;
rep(i,n)rep(j,i) a[i][j]=a[j][i]*(-1);
auto f=[&](int i,int j){
if(a[i][j]>0) return i;
return j;
};
vector<vector<ll>> dp(1<<n,vector<ll>(n,0));
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)if(i!=j){
int k=f(i,j);
dp[(1<<i)+(1<<j)][k]=2;
}
}
for(int bit=0;bit<(1<<n);bit++){
int popcount=__builtin_popcount(bit);
if(popcount>=4 and popcount%2==0){
for(auto &l:enumerate_subset(bit)){
if(__builtin_popcount(l)==popcount/2){
int r=(bit^l);
for(int i=0;i<n;i++)if((l>>i)&1){
for(int j=0;j<n;j++)if((r>>j)&1){
int k=f(i,j);
dp[bit][k]+=dp[l][i]*dp[r][j];
}
}
}
}
}
}
rep(i,n){
cout<<dp[(1<<n)-1][i]<<endl;
}
return 0;
}
mugen_1337