結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー H3PO4H3PO4
提出日時 2022-12-21 09:23:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 497 ms / 1,000 ms
コード長 663 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 83,852 KB
最終ジャッジ日時 2023-10-18 00:18:04
合計ジャッジ時間 26,348 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 447 ms
83,832 KB
testcase_01 AC 467 ms
83,840 KB
testcase_02 AC 432 ms
83,704 KB
testcase_03 AC 483 ms
83,840 KB
testcase_04 AC 483 ms
83,848 KB
testcase_05 AC 479 ms
83,836 KB
testcase_06 AC 482 ms
83,844 KB
testcase_07 AC 485 ms
83,844 KB
testcase_08 AC 480 ms
83,832 KB
testcase_09 AC 483 ms
83,840 KB
testcase_10 AC 488 ms
83,840 KB
testcase_11 AC 477 ms
83,832 KB
testcase_12 AC 482 ms
83,844 KB
testcase_13 AC 478 ms
83,836 KB
testcase_14 AC 485 ms
83,848 KB
testcase_15 AC 486 ms
83,848 KB
testcase_16 AC 479 ms
83,844 KB
testcase_17 AC 491 ms
83,840 KB
testcase_18 AC 493 ms
83,836 KB
testcase_19 AC 484 ms
83,844 KB
testcase_20 AC 471 ms
83,840 KB
testcase_21 AC 482 ms
83,848 KB
testcase_22 AC 488 ms
83,840 KB
testcase_23 AC 490 ms
83,840 KB
testcase_24 AC 497 ms
83,836 KB
testcase_25 AC 485 ms
83,844 KB
testcase_26 AC 486 ms
83,844 KB
testcase_27 AC 467 ms
83,832 KB
testcase_28 AC 445 ms
83,836 KB
testcase_29 AC 451 ms
83,836 KB
testcase_30 AC 456 ms
83,836 KB
testcase_31 AC 459 ms
83,840 KB
testcase_32 AC 462 ms
83,840 KB
testcase_33 AC 465 ms
83,840 KB
testcase_34 AC 473 ms
83,836 KB
testcase_35 AC 469 ms
83,832 KB
testcase_36 AC 469 ms
83,832 KB
testcase_37 AC 476 ms
83,848 KB
testcase_38 AC 477 ms
83,844 KB
testcase_39 AC 476 ms
83,840 KB
testcase_40 AC 476 ms
83,840 KB
testcase_41 AC 477 ms
83,848 KB
testcase_42 AC 476 ms
83,844 KB
testcase_43 AC 476 ms
83,852 KB
testcase_44 AC 476 ms
83,848 KB
testcase_45 AC 473 ms
83,828 KB
testcase_46 AC 480 ms
83,852 KB
testcase_47 AC 431 ms
83,704 KB
testcase_48 AC 483 ms
83,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 19
bit_count = lambda x: bin(x).count("1")

exist_table = [[False] * N for _ in range(N)]
for i in range(N):
    L, *A = map(int, input().split())
    for a in A:
        exist_table[i][a - 1] = True

dp0 = [0] * (1 << N)
dp1 = [0] * (1 << N)
dp0[0] = 1
for b in range(1 << N):
    sign = True
    n = bit_count(b)
    for i in range(N):
        if (b >> i) & 1:
            continue
        sign = not sign
        if not exist_table[n][i]:
            continue
        c = b | (1 << i)
        if sign:
            dp1[c] += dp0[b]
            dp0[c] += dp1[b]
        else:
            dp0[c] += dp0[b]
            dp1[c] += dp1[b]
print(dp0[-1], dp1[-1])
0