結果

問題 No.1937 Various Tournament
ユーザー titiatitia
提出日時 2022-05-18 03:33:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,336 ms / 2,000 ms
コード長 1,337 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 81,828 KB
最終ジャッジ日時 2023-10-14 07:40:10
合計ジャッジ時間 44,231 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
77,716 KB
testcase_01 AC 1,254 ms
81,312 KB
testcase_02 AC 1,287 ms
81,352 KB
testcase_03 AC 1,318 ms
81,676 KB
testcase_04 AC 1,336 ms
81,828 KB
testcase_05 AC 117 ms
78,152 KB
testcase_06 AC 1,316 ms
81,368 KB
testcase_07 AC 1,329 ms
81,756 KB
testcase_08 AC 114 ms
78,244 KB
testcase_09 AC 1,328 ms
80,708 KB
testcase_10 AC 113 ms
78,316 KB
testcase_11 AC 1,306 ms
81,096 KB
testcase_12 AC 1,318 ms
80,300 KB
testcase_13 AC 1,279 ms
81,072 KB
testcase_14 AC 1,310 ms
81,000 KB
testcase_15 AC 1,315 ms
81,292 KB
testcase_16 AC 1,336 ms
80,752 KB
testcase_17 AC 1,294 ms
81,192 KB
testcase_18 AC 1,277 ms
81,312 KB
testcase_19 AC 1,263 ms
80,984 KB
testcase_20 AC 113 ms
78,172 KB
testcase_21 AC 106 ms
77,496 KB
testcase_22 AC 1,261 ms
80,996 KB
testcase_23 AC 1,269 ms
81,244 KB
testcase_24 AC 1,290 ms
80,684 KB
testcase_25 AC 115 ms
78,176 KB
testcase_26 AC 1,261 ms
81,336 KB
testcase_27 AC 103 ms
77,760 KB
testcase_28 AC 1,241 ms
81,300 KB
testcase_29 AC 111 ms
78,192 KB
testcase_30 AC 1,310 ms
80,892 KB
testcase_31 AC 1,244 ms
80,492 KB
testcase_32 AC 1,293 ms
80,488 KB
testcase_33 AC 1,235 ms
80,640 KB
testcase_34 AC 1,231 ms
81,264 KB
testcase_35 AC 1,262 ms
81,168 KB
testcase_36 AC 1,272 ms
80,816 KB
testcase_37 AC 116 ms
78,344 KB
testcase_38 AC 118 ms
78,100 KB
testcase_39 AC 1,283 ms
81,140 KB
testcase_40 AC 115 ms
78,180 KB
testcase_41 AC 113 ms
78,196 KB
testcase_42 AC 1,297 ms
81,096 KB
testcase_43 AC 118 ms
78,228 KB
testcase_44 AC 109 ms
77,444 KB
testcase_45 AC 1,311 ms
81,284 KB
testcase_46 AC 119 ms
78,212 KB
testcase_47 AC 109 ms
77,968 KB
testcase_48 AC 109 ms
77,756 KB
testcase_49 AC 120 ms
77,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N=int(input())
S=[list(map(int,input().split())) for i in range(N)]

ANS=[0]*N

def listbit(x):
    for i in range(1<<x):
        count=0
        for j in range(x):
            if i & (1<<j) != 0:
                count+=1
        if count==x//2 and i & (1<<0)==0:
            yield i

LBIT=[-1]*20

LBIT[2]=list(listbit(2))
LBIT[4]=list(listbit(4))
LBIT[8]=list(listbit(8))
LBIT[16]=list(listbit(16))
            

def win(x,y):
    if S[x][y]==1:
        return x
    else:
        return y

def calc(X,f):
    if len(X)==2:
        a,b=X[0],X[1]

        DX=Counter()

        if S[a][b]==1:
            DX[a]=f
        else:
            DX[b]=f
        return DX
        
    DD=Counter()

    for i in LBIT[len(X)]:
        Y=[]
        Z=[]

        for j in range(len(X)):
            if i & (1<<j) == 0:
                Y.append(X[j])
            else:
                Z.append(X[j])

        #print("!",Y,Z)

        if len(Y)==len(X)//2:
            #print(Y,Z)
            D1=calc(Y,f)
            D2=calc(Z,f)

            for d1 in D1:
                for d2 in D2:
                    DD[win(d1,d2)]+=D1[d1]*D2[d2]

    return DD
            


D=calc(list(range(N)),1)

if N==2:
    k=2
elif N==4:
    k=4*2
elif N==8:
    k=16*8
else:
    k=16*16*128

for i in range(N):
    print(D[i]*k)
0