結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー 👑 KazunKazun
提出日時 2022-12-06 22:59:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 233 ms / 1,000 ms
コード長 1,121 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 84,608 KB
最終ジャッジ日時 2024-04-22 18:36:18
合計ジャッジ時間 11,762 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 182 ms
84,096 KB
testcase_01 AC 194 ms
84,224 KB
testcase_02 AC 173 ms
84,096 KB
testcase_03 AC 210 ms
84,096 KB
testcase_04 AC 227 ms
84,224 KB
testcase_05 AC 223 ms
84,352 KB
testcase_06 AC 224 ms
84,224 KB
testcase_07 AC 221 ms
84,096 KB
testcase_08 AC 217 ms
84,480 KB
testcase_09 AC 214 ms
84,480 KB
testcase_10 AC 231 ms
84,224 KB
testcase_11 AC 224 ms
84,224 KB
testcase_12 AC 221 ms
84,096 KB
testcase_13 AC 204 ms
84,224 KB
testcase_14 AC 224 ms
84,224 KB
testcase_15 AC 233 ms
84,224 KB
testcase_16 AC 227 ms
84,096 KB
testcase_17 AC 216 ms
84,480 KB
testcase_18 AC 227 ms
84,608 KB
testcase_19 AC 220 ms
84,224 KB
testcase_20 AC 211 ms
84,224 KB
testcase_21 AC 231 ms
84,224 KB
testcase_22 AC 216 ms
84,608 KB
testcase_23 AC 212 ms
84,096 KB
testcase_24 AC 230 ms
84,096 KB
testcase_25 AC 224 ms
84,480 KB
testcase_26 AC 224 ms
84,352 KB
testcase_27 AC 200 ms
84,096 KB
testcase_28 AC 182 ms
84,480 KB
testcase_29 AC 184 ms
84,352 KB
testcase_30 AC 185 ms
84,224 KB
testcase_31 AC 189 ms
84,352 KB
testcase_32 AC 192 ms
84,224 KB
testcase_33 AC 195 ms
84,224 KB
testcase_34 AC 200 ms
84,480 KB
testcase_35 AC 205 ms
84,224 KB
testcase_36 AC 205 ms
84,352 KB
testcase_37 AC 220 ms
84,224 KB
testcase_38 AC 212 ms
84,224 KB
testcase_39 AC 217 ms
84,480 KB
testcase_40 AC 209 ms
84,224 KB
testcase_41 AC 207 ms
84,096 KB
testcase_42 AC 200 ms
84,352 KB
testcase_43 AC 204 ms
84,224 KB
testcase_44 AC 202 ms
84,224 KB
testcase_45 AC 196 ms
84,224 KB
testcase_46 AC 202 ms
84,224 KB
testcase_47 AC 171 ms
84,480 KB
testcase_48 AC 223 ms
84,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Determinant(A):
    from copy import deepcopy

    N=len(A)
    A=deepcopy(A)
    det=1

    for i in range(N):
        Ai=A[i]
        for j in range(i+1, N):
            Aj=A[j]
            while Aj[i]:
                alpha=Ai[i]//Aj[i]
                if alpha:
                    for k in range(i, N):
                        Ai[k]-=alpha*Aj[k]
                A[i], A[j]=A[j], A[i]
                Ai=A[i]; Aj=A[j]
                det*=-1
        det*=Ai[i]
        if det==0:
            break
    return det

#==================================================
def solve():
    N=19; U=1<<N

    B=[[0]*N for _ in range(N)]
    for i in range(N):
        _,*Ai=map(int,input().split())
        for a in Ai:
            B[i][a-1]=1

    bit=lambda S,k:(S>>k)&1

    popcount=[0]*U
    DP=[0]*U; DP[0]=1
    for S in range(U):
        t=popcount[S]=(popcount[S>>1]+(S&1))
        for i in range(N):
            if bit(S,i)==0 and B[t][i]:
                DP[S|(1<<i)]+=DP[S]

    Y=DP[-1]
    Z=Determinant(B)

    return (Y+Z)//2, (Y-Z)//2

#==================================================
print(*solve())
0