結果
問題 | No.753 最強王者決定戦 |
ユーザー |
![]() |
提出日時 | 2018-11-09 21:55:16 |
言語 | C++17 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 377 ms / 1,000 ms |
コード長 | 1,089 bytes |
コンパイル時間 | 1,829 ms |
使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2022-12-26 19:58:13 |
合計ジャッジ時間 | 4,423 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 374 ms
11,904 KB |
testcase_01 | AC | 377 ms
11,812 KB |
testcase_02 | AC | 371 ms
11,828 KB |
testcase_03 | AC | 370 ms
11,892 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using int64 = long long; int S[16][16]; int pop[1 << 16]; int64 dp[1 << 16][16]; int64 rec(int win, int bit) { if(~dp[bit][win]) return dp[bit][win]; int64 ret = 0, dep = pop[bit] >> 1; if(dep == 0) return 1; for(int i = bit; i > 0; i = (i - 1) & bit) { int other = i ^bit; if((i >> win) & 1) { if(pop[i] == dep && pop[other] == dep) { for(int j = 0; j < 16; j++) { if((other >> j) & 1) { if(S[win][j] == 1) { ret += rec(win, i) * rec(j, other) * 2; } } } } } } return dp[bit][win] = ret; } int main() { for(int i = 0; i < 16; i++) { for(int j = 0; j < 16; j++) { cin >> S[i][j]; } } for(int i = 0; i < 16; i++) { for(int j = 0; j < 16; j++) { if(S[i][j] == 0) { S[i][j] = -S[j][i]; } } } for(int i = 0; i < 1 << 16; i++) { pop[i] = __builtin_popcount(i); } memset(dp, -1, sizeof(dp)); for(int i = 0; i < 16; i++) { cout << rec(i, (1 << 16) - 1) << endl; } }