結果

問題 No.1937 Various Tournament
ユーザー chineristACchineristAC
提出日時 2021-12-28 02:30:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 903 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 86,320 KB
実行使用メモリ 95,544 KB
最終ジャッジ日時 2023-09-20 06:45:38
合計ジャッジ時間 33,741 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
81,144 KB
testcase_01 AC 883 ms
95,472 KB
testcase_02 AC 876 ms
95,212 KB
testcase_03 AC 867 ms
95,060 KB
testcase_04 AC 878 ms
95,108 KB
testcase_05 AC 165 ms
81,744 KB
testcase_06 AC 873 ms
95,380 KB
testcase_07 AC 878 ms
95,376 KB
testcase_08 AC 167 ms
81,832 KB
testcase_09 AC 878 ms
95,292 KB
testcase_10 AC 167 ms
81,640 KB
testcase_11 AC 860 ms
95,492 KB
testcase_12 AC 870 ms
95,492 KB
testcase_13 AC 871 ms
95,376 KB
testcase_14 AC 867 ms
95,536 KB
testcase_15 AC 868 ms
95,292 KB
testcase_16 AC 875 ms
95,196 KB
testcase_17 AC 875 ms
95,340 KB
testcase_18 AC 878 ms
95,320 KB
testcase_19 AC 903 ms
95,196 KB
testcase_20 AC 167 ms
81,812 KB
testcase_21 AC 150 ms
81,348 KB
testcase_22 AC 868 ms
95,372 KB
testcase_23 AC 889 ms
95,488 KB
testcase_24 AC 883 ms
95,104 KB
testcase_25 AC 169 ms
81,992 KB
testcase_26 AC 877 ms
95,268 KB
testcase_27 AC 153 ms
81,252 KB
testcase_28 AC 888 ms
95,480 KB
testcase_29 AC 166 ms
82,060 KB
testcase_30 AC 875 ms
95,352 KB
testcase_31 AC 881 ms
95,204 KB
testcase_32 AC 886 ms
95,192 KB
testcase_33 AC 900 ms
95,496 KB
testcase_34 AC 877 ms
95,060 KB
testcase_35 AC 878 ms
95,432 KB
testcase_36 AC 885 ms
95,444 KB
testcase_37 AC 166 ms
81,808 KB
testcase_38 AC 168 ms
82,052 KB
testcase_39 AC 880 ms
95,508 KB
testcase_40 AC 168 ms
81,992 KB
testcase_41 AC 171 ms
81,844 KB
testcase_42 AC 886 ms
95,292 KB
testcase_43 AC 166 ms
81,640 KB
testcase_44 AC 151 ms
81,320 KB
testcase_45 AC 876 ms
95,544 KB
testcase_46 AC 164 ms
81,872 KB
testcase_47 AC 152 ms
81,024 KB
testcase_48 AC 150 ms
81,152 KB
testcase_49 AC 166 ms
81,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from os import cpu_count
import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

popcount = [bin(i).count("1") for i in range(2**16)]


N = int(input())
A = [li() for i in range(N)]
#A = [[random.randint(0,99)&1 for j in range(N)] for i in range(N)]
#for i in range(N):
    #for j in range(i+1,N):
        #A[i][j] = 1 - A[j][i]

dp = [[0 for i in range(N)] for S in range(1<<N)]
for i in range(N):
    dp[2**i][i] = 1

for S in range(1<<N):

    n = bin(S).count("1")
    if n not in (2,4,8,16):
        continue

    tmp = S
    while tmp:
        t = S - tmp
        if popcount[tmp]!=popcount[S-tmp]:
            tmp = (tmp-1) & S
            continue
        for j in range(N):
            if tmp>>j & 1==0:
                continue
            for k in range(j+1,N):
                if A[j][k]:
                    dp[S][j] += dp[tmp][j] * dp[S-tmp][k] * 2
                else:
                    dp[S][k] += dp[tmp][j] * dp[S-tmp][k] * 2
        tmp = (tmp-1) & S

for k in range(N):
    print(dp[2**N-1][k])

0