結果
問題 |
No.2121 帰属関係と充足可能性
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:35:37 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,055 bytes |
コンパイル時間 | 1,991 ms |
コンパイル使用メモリ | 81,676 KB |
実行使用メモリ | 110,832 KB |
最終ジャッジ日時 | 2025-04-16 16:38:58 |
合計ジャッジ時間 | 4,299 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 1 -- * 43 |
ソースコード
import sys from itertools import combinations def generate_v(n): """Generate the cumulative hierarchy V_n as a list of frozensets.""" if n == 0: return [frozenset()] prev = generate_v(n-1) subsets = set() for r in range(len(prev) + 1): for subset in combinations(prev, r): subsets.add(frozenset(subset)) return list(subsets) def main(): input = sys.stdin.read().split() N = int(input[0]) A = list(map(int, input[1:7])) A0, A1, A2, A3, A4, A5 = A # Generate V_N try: vn = generate_v(N) except RecursionError: print("NO") return # Precompute all elements of V_N elements = vn # Iterate all possible m0, m1, m2 in V_N found = False for m0 in elements: for m1 in elements: for m2 in elements: # Map A0-A5 to the corresponding m variables ma0 = [m0, m1, m2][A0] ma1 = [m0, m1, m2][A1] ma2 = [m0, m1, m2][A2] ma3 = [m0, m1, m2][A3] ma4 = [m0, m1, m2][A4] ma5 = [m0, m1, m2][A5] # Check condition 1: ∀x3 ∈ V_N, x3 ∈ ma0 → x3 ∈ ma1 cond1 = True for x3 in elements: if x3 in ma0: if x3 not in ma1: cond1 = False break # Check condition 2: ma1 ∈ ma2 cond2 = (ma1 in ma2) # Check condition 3: ma3 ∈ ma2 cond3 = (ma3 in ma2) # Check condition 4: ma4 ∈ ma2 cond4 = (ma4 in ma2) # Check condition 5: ma5 ∈ ma0 cond5 = (ma5 in ma0) if cond1 and cond2 and cond3 and cond4 and cond5: found = True break if found: break if found: break print("YES" if found else "NO") if __name__ == "__main__": main()