結果

問題 No.1937 Various Tournament
ユーザー chineristACchineristAC
提出日時 2021-12-28 02:30:28
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 899 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 279 ms
使用メモリ 99,712 KB
最終ジャッジ日時 2023-02-08 14:32:12
合計ジャッジ時間 33,023 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 163 ms
85,604 KB
testcase_01 AC 876 ms
99,588 KB
testcase_02 AC 881 ms
99,684 KB
testcase_03 AC 876 ms
99,304 KB
testcase_04 AC 885 ms
99,704 KB
testcase_05 AC 181 ms
85,844 KB
testcase_06 AC 890 ms
99,292 KB
testcase_07 AC 887 ms
99,516 KB
testcase_08 AC 183 ms
86,000 KB
testcase_09 AC 873 ms
99,340 KB
testcase_10 AC 181 ms
85,916 KB
testcase_11 AC 873 ms
99,456 KB
testcase_12 AC 883 ms
99,576 KB
testcase_13 AC 886 ms
99,452 KB
testcase_14 AC 868 ms
99,644 KB
testcase_15 AC 873 ms
99,580 KB
testcase_16 AC 899 ms
99,660 KB
testcase_17 AC 870 ms
99,584 KB
testcase_18 AC 893 ms
99,704 KB
testcase_19 AC 883 ms
99,632 KB
testcase_20 AC 185 ms
85,996 KB
testcase_21 AC 164 ms
85,544 KB
testcase_22 AC 881 ms
99,616 KB
testcase_23 AC 884 ms
99,712 KB
testcase_24 AC 881 ms
99,540 KB
testcase_25 AC 182 ms
85,904 KB
testcase_26 AC 887 ms
99,612 KB
testcase_27 AC 163 ms
85,472 KB
testcase_28 AC 888 ms
99,644 KB
testcase_29 AC 180 ms
85,988 KB
testcase_30 AC 878 ms
99,488 KB
testcase_31 AC 887 ms
99,552 KB
testcase_32 AC 874 ms
99,708 KB
testcase_33 AC 898 ms
99,616 KB
testcase_34 AC 866 ms
99,584 KB
testcase_35 AC 892 ms
99,300 KB
testcase_36 AC 873 ms
99,576 KB
testcase_37 AC 181 ms
86,184 KB
testcase_38 AC 182 ms
86,036 KB
testcase_39 AC 887 ms
99,652 KB
testcase_40 AC 183 ms
86,208 KB
testcase_41 AC 182 ms
86,132 KB
testcase_42 AC 869 ms
99,576 KB
testcase_43 AC 183 ms
86,120 KB
testcase_44 AC 161 ms
85,388 KB
testcase_45 AC 892 ms
99,572 KB
testcase_46 AC 180 ms
86,084 KB
testcase_47 AC 159 ms
85,464 KB
testcase_48 AC 161 ms
85,520 KB
testcase_49 AC 179 ms
86,112 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