結果

問題 No.1937 Various Tournament
ユーザー sotanishysotanishy
提出日時 2022-05-13 22:07:02
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 834 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 272 ms
使用メモリ 95,552 KB
最終ジャッジ日時 2023-02-21 14:42:48
合計ジャッジ時間 29,608 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 86 ms
75,772 KB
testcase_01 AC 821 ms
95,436 KB
testcase_02 AC 822 ms
95,004 KB
testcase_03 AC 832 ms
95,152 KB
testcase_04 AC 820 ms
95,072 KB
testcase_05 AC 97 ms
80,764 KB
testcase_06 AC 823 ms
95,380 KB
testcase_07 AC 834 ms
95,148 KB
testcase_08 AC 98 ms
81,064 KB
testcase_09 AC 825 ms
95,360 KB
testcase_10 AC 96 ms
80,872 KB
testcase_11 AC 819 ms
95,240 KB
testcase_12 AC 831 ms
95,240 KB
testcase_13 AC 827 ms
95,032 KB
testcase_14 AC 830 ms
95,344 KB
testcase_15 AC 833 ms
95,072 KB
testcase_16 AC 831 ms
95,436 KB
testcase_17 AC 825 ms
95,300 KB
testcase_18 AC 829 ms
95,148 KB
testcase_19 AC 831 ms
95,064 KB
testcase_20 AC 97 ms
81,048 KB
testcase_21 AC 82 ms
75,756 KB
testcase_22 AC 832 ms
95,292 KB
testcase_23 AC 824 ms
95,404 KB
testcase_24 AC 830 ms
95,052 KB
testcase_25 AC 97 ms
80,908 KB
testcase_26 AC 828 ms
95,336 KB
testcase_27 AC 83 ms
75,508 KB
testcase_28 AC 826 ms
95,168 KB
testcase_29 AC 97 ms
80,936 KB
testcase_30 AC 828 ms
95,348 KB
testcase_31 AC 824 ms
95,204 KB
testcase_32 AC 833 ms
95,004 KB
testcase_33 AC 818 ms
95,364 KB
testcase_34 AC 832 ms
95,408 KB
testcase_35 AC 828 ms
95,552 KB
testcase_36 AC 829 ms
95,328 KB
testcase_37 AC 97 ms
80,788 KB
testcase_38 AC 103 ms
80,860 KB
testcase_39 AC 831 ms
95,036 KB
testcase_40 AC 102 ms
80,684 KB
testcase_41 AC 98 ms
81,080 KB
testcase_42 AC 825 ms
95,152 KB
testcase_43 AC 96 ms
81,196 KB
testcase_44 AC 82 ms
75,760 KB
testcase_45 AC 822 ms
95,332 KB
testcase_46 AC 96 ms
80,964 KB
testcase_47 AC 82 ms
75,696 KB
testcase_48 AC 83 ms
75,572 KB
testcase_49 AC 98 ms
80,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def subset(N, k):
    S = (1<<k)-1
    st = []
    while S < (1<<N):
        st.append(S)
        x = S & -S
        y = S + x
        S = ((S & ~y) // x >> 1) | y
    return st

N = int(input())
S = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * N for _ in range(1<<N)]
# dp[S][i] = number of ways where i wins the tournament of people in S
for i in range(N):
    dp[1<<i][i] = 1
k = 0
while 2**k < N:
    st = subset(N, 2**k)
    for l, X in enumerate(st):
        for Y in st[l+1:]:
            if X&Y:
                continue
            for i in range(N):
                if X>>i&1:
                    for j in range(N):
                        if Y>>j&1:
                            dp[X|Y][i if S[i][j] else j] += dp[X][i] * dp[Y][j] * 2
    k += 1
for i in range(N):
    print(dp[-1][i])
0