結果
問題 |
No.2121 帰属関係と充足可能性
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:26:14 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,498 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 81,916 KB |
実行使用メモリ | 117,776 KB |
最終ジャッジ日時 | 2025-06-12 21:27:28 |
合計ジャッジ時間 | 4,255 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 TLE * 1 -- * 42 |
ソースコード
import sys from itertools import combinations def generate_v(n): if n == 0: return [frozenset()] vs = [] current = frozenset() vs.append(current) for i in range(1, n+1): prev = vs[i-1] elements = list(prev) k = len(elements) subsets = [] for r in range(k+1): for comb in combinations(elements, r): subset = frozenset(comb) subsets.append(subset) current = frozenset(subsets) vs.append(current) return vs 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 if N == 0: print("NO") return try: vs = generate_v(N) V_N = vs[N] except: print("NO") return for m0 in V_N: for m1 in V_N: for m2 in V_N: 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] cond1 = ma0.issubset(ma1) cond2 = ma1 in ma2 cond3 = ma3 in ma2 cond4 = ma4 in ma2 cond5 = ma5 in ma0 if cond1 and cond2 and cond3 and cond4 and cond5: print("YES") return print("NO") if __name__ == "__main__": main()