結果

問題 No.1937 Various Tournament
ユーザー sotanishysotanishy
提出日時 2022-05-13 22:07:02
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 858 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 91,324 KB
最終ジャッジ日時 2023-09-29 07:26:27
合計ジャッジ時間 29,677 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,376 KB
testcase_01 AC 837 ms
91,028 KB
testcase_02 AC 838 ms
91,136 KB
testcase_03 AC 829 ms
91,148 KB
testcase_04 AC 817 ms
91,160 KB
testcase_05 AC 80 ms
76,712 KB
testcase_06 AC 845 ms
91,168 KB
testcase_07 AC 852 ms
91,196 KB
testcase_08 AC 83 ms
76,456 KB
testcase_09 AC 829 ms
91,228 KB
testcase_10 AC 80 ms
76,552 KB
testcase_11 AC 839 ms
91,136 KB
testcase_12 AC 847 ms
91,164 KB
testcase_13 AC 848 ms
91,160 KB
testcase_14 AC 847 ms
91,164 KB
testcase_15 AC 845 ms
91,288 KB
testcase_16 AC 835 ms
91,076 KB
testcase_17 AC 839 ms
91,136 KB
testcase_18 AC 850 ms
91,132 KB
testcase_19 AC 838 ms
91,084 KB
testcase_20 AC 81 ms
76,808 KB
testcase_21 AC 70 ms
71,360 KB
testcase_22 AC 830 ms
91,140 KB
testcase_23 AC 834 ms
91,000 KB
testcase_24 AC 833 ms
91,164 KB
testcase_25 AC 79 ms
76,680 KB
testcase_26 AC 841 ms
91,156 KB
testcase_27 AC 69 ms
71,500 KB
testcase_28 AC 839 ms
90,996 KB
testcase_29 AC 82 ms
76,780 KB
testcase_30 AC 834 ms
91,200 KB
testcase_31 AC 837 ms
91,004 KB
testcase_32 AC 849 ms
91,004 KB
testcase_33 AC 842 ms
91,288 KB
testcase_34 AC 858 ms
91,136 KB
testcase_35 AC 836 ms
91,196 KB
testcase_36 AC 822 ms
90,860 KB
testcase_37 AC 84 ms
76,760 KB
testcase_38 AC 80 ms
76,444 KB
testcase_39 AC 835 ms
91,232 KB
testcase_40 AC 80 ms
76,596 KB
testcase_41 AC 82 ms
76,860 KB
testcase_42 AC 823 ms
91,220 KB
testcase_43 AC 81 ms
76,660 KB
testcase_44 AC 69 ms
71,340 KB
testcase_45 AC 836 ms
91,324 KB
testcase_46 AC 80 ms
76,760 KB
testcase_47 AC 69 ms
71,508 KB
testcase_48 AC 70 ms
71,704 KB
testcase_49 AC 81 ms
76,720 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