結果
| 問題 |
No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2022-11-27 05:09:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 699 bytes |
| コンパイル時間 | 312 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 253,196 KB |
| 最終ジャッジ日時 | 2024-10-14 18:03:42 |
| 合計ジャッジ時間 | 3,444 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 45 |
ソースコード
from functools import lru_cache
def solve():
N=19
B=[[0]*N for _ in range(N)]
for i in range(N):
_,*Ai=map(int,input().split())
for a in Ai:
B[i][a-1]=1
popcount=lambda S:bin(S).count("1")
bit=lambda S,k:(S>>k)&1
@lru_cache(maxsize=None)
def calc(S, sgn):
pop=popcount(S)
if pop==N:
return sgn==0
unused=[i for i in range(N) if not bit(S,i)]
X=0
for t in range(len(unused)):
if B[pop][unused[t]]==1:
X+=calc(S|(1<<unused[t]), sgn^(t%2))
return X
return calc(0,0), calc(0,1)
#==================================================
print(*solve())
Kazun