結果

問題 No.753 最強王者決定戦
ユーザー mkawa2mkawa2
提出日時 2022-02-01 15:10:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 568 ms / 1,000 ms
コード長 1,690 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 88,836 KB
最終ジャッジ日時 2023-09-02 02:30:40
合計ジャッジ時間 3,844 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 560 ms
88,656 KB
testcase_01 AC 568 ms
88,708 KB
testcase_02 AC 564 ms
88,460 KB
testcase_03 AC 568 ms
88,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = (1 << 63)-1
inf = (1 << 32)-1
# md = 10**9+7
md = 998244353

pc = [0]
for _ in range(16): pc += list(map(lambda x: x+1, pc))
ss = [[] for _ in range(17)]
for s in range(1 << 16): ss[pc[s]].append(s)

aa = LLI(16)

dp = [[0]*(1 << 16) for _ in range(16)]
for i in range(16):
    s = 1 << i
    for j in range(i+1, 16):
        if aa[i][j] == -1:
            aa[i][j] = 0
            aa[j][i] = 1
        if aa[i][j]:
            dp[i][s | 1 << j] = 2
        else:
            dp[j][s | 1 << j] = 2

for c in [4, 8, 16]:
    for s in ss[c]:
        for t in ss[c//2]:
            if s & t != t: continue
            u = s ^ t
            if t > u: continue
            for i in range(16):
                if t >> i & 1 == 0: continue
                for j in range(16):
                    if u >> j & 1 == 0: continue
                    if aa[i][j]:
                        dp[i][s] += dp[i][t]*dp[j][u]*2
                    else:
                        dp[j][s] += dp[i][t]*dp[j][u]*2

for i in range(16): print(dp[i][-1])
0