1function twoSat(n, clauses) {
2 const g = buildImplicationGraph(n, clauses);
3 const sccId = tarjanSCC(2 * n, g);
4 for (let i = 0; i < n; i++) {
5 if (sccId[2*i] === sccId[2*i+1]) return null;
6 }
7 // Tarjan 编号小 = 缩点后拓扑序靠后(汇点侧),赋 true
8 return Array.from({length: n}, (_, i) => sccId[2*i] < sccId[2*i+1]);
9}