結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー ああいいああいい
提出日時 2023-01-02 10:11:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 496 ms / 1,000 ms
コード長 551 bytes
コンパイル時間 1,339 ms
コンパイル使用メモリ 86,564 KB
実行使用メモリ 125,076 KB
最終ジャッジ日時 2023-08-17 23:23:22
合計ジャッジ時間 27,064 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 396 ms
124,840 KB
testcase_01 AC 453 ms
124,920 KB
testcase_02 AC 338 ms
124,680 KB
testcase_03 AC 492 ms
124,768 KB
testcase_04 AC 488 ms
124,916 KB
testcase_05 AC 481 ms
124,772 KB
testcase_06 AC 475 ms
124,796 KB
testcase_07 AC 484 ms
124,808 KB
testcase_08 AC 476 ms
124,648 KB
testcase_09 AC 479 ms
124,752 KB
testcase_10 AC 479 ms
124,792 KB
testcase_11 AC 478 ms
124,892 KB
testcase_12 AC 476 ms
124,896 KB
testcase_13 AC 476 ms
124,864 KB
testcase_14 AC 486 ms
124,884 KB
testcase_15 AC 484 ms
124,884 KB
testcase_16 AC 466 ms
124,844 KB
testcase_17 AC 470 ms
124,832 KB
testcase_18 AC 491 ms
124,884 KB
testcase_19 AC 481 ms
124,884 KB
testcase_20 AC 464 ms
124,888 KB
testcase_21 AC 482 ms
124,872 KB
testcase_22 AC 478 ms
124,676 KB
testcase_23 AC 475 ms
124,784 KB
testcase_24 AC 482 ms
124,704 KB
testcase_25 AC 483 ms
124,800 KB
testcase_26 AC 488 ms
124,684 KB
testcase_27 AC 453 ms
124,780 KB
testcase_28 AC 400 ms
124,744 KB
testcase_29 AC 406 ms
124,908 KB
testcase_30 AC 409 ms
124,764 KB
testcase_31 AC 419 ms
124,960 KB
testcase_32 AC 427 ms
124,756 KB
testcase_33 AC 431 ms
124,636 KB
testcase_34 AC 440 ms
124,884 KB
testcase_35 AC 446 ms
124,860 KB
testcase_36 AC 459 ms
124,836 KB
testcase_37 AC 463 ms
124,632 KB
testcase_38 AC 466 ms
124,848 KB
testcase_39 AC 474 ms
124,772 KB
testcase_40 AC 485 ms
125,076 KB
testcase_41 AC 484 ms
124,868 KB
testcase_42 AC 490 ms
124,768 KB
testcase_43 AC 484 ms
124,660 KB
testcase_44 AC 496 ms
124,764 KB
testcase_45 AC 488 ms
124,756 KB
testcase_46 AC 480 ms
124,880 KB
testcase_47 AC 330 ms
124,720 KB
testcase_48 AC 485 ms
124,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 19
dat = [None for _ in range(N)]
for _ in range(N):
    L,*A = map(int,input().split())
    dat[_] = set(A)

dp = [[0] * 2 for _ in range(1 << N)]

dp[0][0] = 1
for bit in range(1 << N):
    n = 0
    for i in range(N):
        if bit >> i & 1:
            n += 1
    m = 0
    for i in range(N):
        if bit >> i & 1:
            m += 1
        else:
            if i + 1 not in dat[n]:continue
            dp[bit | (1 << i)][(n - m) % 2] += dp[bit][0]
            dp[bit | (1 << i)][(n - m + 1) % 2] += dp[bit][1]
print(dp[-1][0],dp[-1][1])
0