結果

問題 No.1937 Various Tournament
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-13 22:54:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,574 ms / 2,000 ms
コード長 1,277 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 94,492 KB
最終ジャッジ日時 2023-09-29 08:36:07
合計ジャッジ時間 52,618 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,420 KB
testcase_01 AC 1,546 ms
94,072 KB
testcase_02 AC 1,555 ms
93,792 KB
testcase_03 AC 1,569 ms
94,308 KB
testcase_04 AC 1,554 ms
93,832 KB
testcase_05 AC 92 ms
76,428 KB
testcase_06 AC 1,558 ms
94,220 KB
testcase_07 AC 1,559 ms
94,304 KB
testcase_08 AC 89 ms
76,604 KB
testcase_09 AC 1,550 ms
94,384 KB
testcase_10 AC 92 ms
76,648 KB
testcase_11 AC 1,540 ms
94,312 KB
testcase_12 AC 1,545 ms
93,728 KB
testcase_13 AC 1,550 ms
93,676 KB
testcase_14 AC 1,572 ms
93,960 KB
testcase_15 AC 1,554 ms
94,344 KB
testcase_16 AC 1,539 ms
93,924 KB
testcase_17 AC 1,535 ms
94,244 KB
testcase_18 AC 1,557 ms
94,172 KB
testcase_19 AC 1,543 ms
94,184 KB
testcase_20 AC 89 ms
76,068 KB
testcase_21 AC 75 ms
71,232 KB
testcase_22 AC 1,569 ms
93,676 KB
testcase_23 AC 1,551 ms
93,616 KB
testcase_24 AC 1,551 ms
94,232 KB
testcase_25 AC 89 ms
76,552 KB
testcase_26 AC 1,559 ms
94,156 KB
testcase_27 AC 74 ms
71,332 KB
testcase_28 AC 1,559 ms
94,304 KB
testcase_29 AC 90 ms
76,424 KB
testcase_30 AC 1,541 ms
94,492 KB
testcase_31 AC 1,556 ms
94,164 KB
testcase_32 AC 1,554 ms
94,468 KB
testcase_33 AC 1,554 ms
94,244 KB
testcase_34 AC 1,574 ms
93,656 KB
testcase_35 AC 1,550 ms
93,692 KB
testcase_36 AC 1,574 ms
94,172 KB
testcase_37 AC 91 ms
76,300 KB
testcase_38 AC 90 ms
76,300 KB
testcase_39 AC 1,560 ms
94,056 KB
testcase_40 AC 88 ms
76,524 KB
testcase_41 AC 91 ms
76,644 KB
testcase_42 AC 1,562 ms
94,400 KB
testcase_43 AC 91 ms
76,668 KB
testcase_44 AC 73 ms
71,272 KB
testcase_45 AC 1,558 ms
93,696 KB
testcase_46 AC 91 ms
76,516 KB
testcase_47 AC 72 ms
71,264 KB
testcase_48 AC 72 ms
71,196 KB
testcase_49 AC 89 ms
76,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
M = (N - 1).bit_length()
S = tuple(tuple(map(int, input().split())) for _ in range(N))


"""
dp[S, i]
選手の集合S, 勝者i -> 何通り
"""
bit = [[] for _ in range(5)]
for b in range(1, 1 << N):
    pc = bin(b).count("1")
    if pc == 1:
        bit[0].append(b)
    elif pc == 2:
        bit[1].append(b)
    elif pc == 4:
        bit[2].append(b)
    elif pc == 8:
        bit[3].append(b)
    elif pc == 16:
        bit[4].append(b)


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

for i in range(M - 1):
    for x in bit[i]:
        for j in range(N):
            if ~(x >> j) & 1:
                continue
            for y in bit[i]:
                if x & y:
                    continue
                for k in range(N):
                    if ~(y >> k) & 1:
                        continue
                    win = j if S[j][k] else k
                    dp[x | y][win] += dp[x][j] * dp[y][k]


mask = (1 << N) - 1
for x in bit[M-1]:
    y = mask ^ x
    for i in range(N):
        if (x >> i) & 1:
            for j in range(N):
                if (y >> j) & 1:
                    win = i if S[i][j] else j
                    dp[mask][win] += dp[x][i] * dp[y][j]


for i in range(N):
    print(dp[mask][i])
0