結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー ShirotsumeShirotsume
提出日時 2022-12-09 01:22:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 292 ms / 1,000 ms
コード長 1,043 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 88,960 KB
最終ジャッジ日時 2024-04-22 18:54:03
合計ジャッジ時間 14,500 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 203 ms
88,728 KB
testcase_01 AC 227 ms
88,704 KB
testcase_02 AC 196 ms
88,576 KB
testcase_03 AC 279 ms
88,548 KB
testcase_04 AC 286 ms
88,704 KB
testcase_05 AC 249 ms
88,520 KB
testcase_06 AC 286 ms
88,616 KB
testcase_07 AC 241 ms
88,448 KB
testcase_08 AC 246 ms
88,448 KB
testcase_09 AC 232 ms
88,796 KB
testcase_10 AC 251 ms
88,568 KB
testcase_11 AC 247 ms
88,460 KB
testcase_12 AC 234 ms
88,320 KB
testcase_13 AC 292 ms
88,696 KB
testcase_14 AC 251 ms
88,648 KB
testcase_15 AC 246 ms
88,448 KB
testcase_16 AC 238 ms
88,576 KB
testcase_17 AC 290 ms
88,496 KB
testcase_18 AC 290 ms
88,660 KB
testcase_19 AC 285 ms
88,708 KB
testcase_20 AC 289 ms
88,676 KB
testcase_21 AC 239 ms
88,576 KB
testcase_22 AC 286 ms
88,748 KB
testcase_23 AC 232 ms
88,336 KB
testcase_24 AC 283 ms
88,832 KB
testcase_25 AC 287 ms
88,608 KB
testcase_26 AC 254 ms
88,448 KB
testcase_27 AC 288 ms
88,480 KB
testcase_28 AC 205 ms
88,576 KB
testcase_29 AC 209 ms
88,424 KB
testcase_30 AC 214 ms
88,524 KB
testcase_31 AC 220 ms
88,448 KB
testcase_32 AC 222 ms
88,448 KB
testcase_33 AC 225 ms
88,320 KB
testcase_34 AC 229 ms
88,320 KB
testcase_35 AC 231 ms
88,704 KB
testcase_36 AC 281 ms
88,652 KB
testcase_37 AC 281 ms
88,704 KB
testcase_38 AC 279 ms
88,576 KB
testcase_39 AC 280 ms
88,576 KB
testcase_40 AC 279 ms
88,668 KB
testcase_41 AC 275 ms
88,960 KB
testcase_42 AC 276 ms
88,704 KB
testcase_43 AC 273 ms
88,824 KB
testcase_44 AC 275 ms
88,588 KB
testcase_45 AC 276 ms
88,448 KB
testcase_46 AC 277 ms
88,576 KB
testcase_47 AC 190 ms
88,420 KB
testcase_48 AC 282 ms
88,512 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 = []
for i in range(n):
    x = li()
    now = 0
    for v in x[1:]:
        now += 2 ** (v-1)
    A.append(now)
ppcnt = [0] * (1 << n)
for i in range(1, 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):
    cnt = ppcnt[bit]
    for i in range(n):
        if 1 & (bit >> i):
            cnt -= 1
        if not(1 & (bit >> i)):
            if 1 & (A[i] >> (ppcnt[bit])):
                if cnt % 2:
                    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