結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー ShirotsumeShirotsume
提出日時 2022-12-09 00:40:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 90,776 KB
最終ジャッジ日時 2024-04-22 18:49:46
合計ジャッジ時間 12,568 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 193 ms
88,704 KB
testcase_01 WA -
testcase_02 AC 172 ms
88,448 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 220 ms
88,448 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 260 ms
88,448 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 172 ms
88,404 KB
testcase_48 AC 248 ms
88,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
sys.setrecursionlimit(5 * 10 ** 5)
from pypyjit import set_param
set_param('max_unroll_recursion=-1')
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = 19
A = []
even = 0
odd = 0
for i in range(n):
    x = li()
    now = 0
    for v in x[1:]:
        now |= 2 ** (v-1)
    A.append(now)
    if i % 2:
        odd |= now
    else:
        even |= now

ppcnt = [0] * (1 << n)
for i in range(1<<n):
    ppcnt[i] = ppcnt[i//2] + i % 2

dp0 = [0] * (1<<n)
dp1 = [0] * (1<<n)
dp0[0] = 1
for bit in range(1<<n):
    for i in range(n):
        if not(1 & (bit >> i)):
            if 1 & (A[i] >> (ppcnt[bit])):
                if i != ppcnt[bit] + 1:
                    dp1[bit | (1<<i)] += dp0[bit]
                    dp0[bit | (1<<i)] += dp1[bit]
                else:
                    dp1[bit | (1<<i)] += dp1[bit]
                    dp0[bit | (1<<i)] += dp0[bit]


print(dp0[-1], dp1[-1])
0