結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー mkawa2mkawa2
提出日時 2022-12-09 00:30:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 426 ms / 1,000 ms
コード長 1,178 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 108,672 KB
最終ジャッジ日時 2024-04-22 18:48:08
合計ジャッジ時間 14,093 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
91,264 KB
testcase_01 AC 88 ms
96,000 KB
testcase_02 AC 70 ms
91,136 KB
testcase_03 AC 339 ms
108,544 KB
testcase_04 AC 193 ms
108,288 KB
testcase_05 AC 318 ms
108,160 KB
testcase_06 AC 180 ms
106,752 KB
testcase_07 AC 267 ms
108,288 KB
testcase_08 AC 335 ms
108,288 KB
testcase_09 AC 122 ms
100,352 KB
testcase_10 AC 300 ms
108,288 KB
testcase_11 AC 199 ms
108,288 KB
testcase_12 AC 104 ms
99,072 KB
testcase_13 AC 177 ms
108,288 KB
testcase_14 AC 227 ms
108,160 KB
testcase_15 AC 278 ms
108,160 KB
testcase_16 AC 310 ms
108,544 KB
testcase_17 AC 354 ms
108,416 KB
testcase_18 AC 301 ms
108,288 KB
testcase_19 AC 331 ms
108,544 KB
testcase_20 AC 84 ms
96,256 KB
testcase_21 AC 383 ms
108,544 KB
testcase_22 AC 159 ms
107,136 KB
testcase_23 AC 199 ms
108,416 KB
testcase_24 AC 390 ms
108,672 KB
testcase_25 AC 288 ms
108,416 KB
testcase_26 AC 281 ms
108,416 KB
testcase_27 AC 265 ms
108,288 KB
testcase_28 AC 70 ms
91,264 KB
testcase_29 AC 75 ms
93,568 KB
testcase_30 AC 83 ms
95,872 KB
testcase_31 AC 83 ms
96,128 KB
testcase_32 AC 92 ms
97,536 KB
testcase_33 AC 115 ms
99,712 KB
testcase_34 AC 151 ms
104,960 KB
testcase_35 AC 214 ms
108,416 KB
testcase_36 AC 268 ms
108,416 KB
testcase_37 AC 333 ms
108,416 KB
testcase_38 AC 372 ms
108,416 KB
testcase_39 AC 398 ms
108,288 KB
testcase_40 AC 426 ms
108,544 KB
testcase_41 AC 422 ms
108,160 KB
testcase_42 AC 347 ms
108,288 KB
testcase_43 AC 348 ms
108,288 KB
testcase_44 AC 415 ms
108,288 KB
testcase_45 AC 335 ms
108,288 KB
testcase_46 AC 419 ms
108,288 KB
testcase_47 AC 71 ms
91,392 KB
testcase_48 AC 363 ms
108,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

pc = [0]
for _ in range(20): pc += [c+1 for c in pc]

aa = [set(LI()[1:]) for _ in range(19)]
# pDB(aa)

dp = [0]*(1 << 20)
dp[0] = 1
for s in range((1 << 20)-2):
    pre = dp[s]
    if pre == 0: continue
    inv = 0
    pcnt = pc[s >> 1]
    for p in range(1, 20)[::-1]:
        if s >> p & 1:
            inv ^= 1
        elif p in aa[pcnt]:
            ns = s ^ inv
            ns |= 1 << p
            dp[ns] += pre

# pDB(dp)
print(dp[-2], dp[-1])
0