結果
| 問題 |
No.753 最強王者決定戦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-01 08:21:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 176 ms / 1,000 ms |
| コード長 | 1,950 bytes |
| コンパイル時間 | 1,578 ms |
| コンパイル使用メモリ | 170,756 KB |
| 実行使用メモリ | 13,496 KB |
| 最終ジャッジ日時 | 2024-06-26 23:56:25 |
| 合計ジャッジ時間 | 2,936 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
int bitcnt(unsigned int x) {
x = (x & 0x55555555) + (x >> 1 & 0x55555555);
x = (x & 0x33333333) + (x >> 2 & 0x33333333);
x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
x = (x & 0x00ff00ff) + (x >> 8 & 0x00ff00ff);
x = (x & 0x0000ffff) + (x >> 16 & 0x0000ffff);
return (int)x;
}
const int N = 16;
ll dp[N][1 << N];
vi men[1 << N];
int in[N][N];
void solve() {
rep(i, N)rep(j, N)cin >> in[i][j];
rep(i, N) dp[i][1 << i] = 1;
for (int S = 1; S < 1 << N; ++S) {
int n = bitcnt(S);
bool ok = false;
rep(i, N)if (n == 1 << i)ok = true;
if (!ok)continue;
rep(i, N)if (S >> i & 1)men[S].push_back(i);
for (int T = S; T > 0; T = (T - 1)&S) {
// 3^16 = 4.30...*10^7
int m = bitcnt(T);
if (m != n / 2) continue;
// C(16,8)+C(8,4)+C(4,2)+C(2,1)
// 16*8*bin(16,8)+8*4*bin(8,4)+4*2*bin(4,2)+2*1*bin(2,1)
const int U = S ^ T;
each(a, men[T])each(b, men[U]) {
int x = a < b ? in[a][b] : -in[b][a];
if (x == 1) {
dp[a][S] += 2 * dp[a][T] * dp[b][U];
}
}
}
}
rep(i, N)cout << dp[i][(1 << N) - 1] << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(15);
solve();
return 0;
}