File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public boolean satisfiable()
9090### answer
9191
9292``` java
93- public java.util . BitSet answer()
93+ public boolean [] answer()
9494```
9595
9696` satisfiable ` を最後に呼んだ時点での、クローズを満たす割当を返す。割当が存在しなかった場合は ` null ` を返す。
@@ -107,4 +107,4 @@ $O(n)$
107107
108108## 使用例
109109
110- [ AtCoder Library Practice Contest H - Two SAT] ( https://atcoder.jp/contests/practice2/submissions/16603939 )
110+ [ AtCoder Library Practice Contest H - Two SAT] ( https://atcoder.jp/contests/practice2/submissions/16647102 )
Original file line number Diff line number Diff line change 1+ /**
2+ * @verified https://atcoder.jp/contests/practice2/submissions/16647102
3+ */
14class TwoSAT {
25 private final int n ;
36 private final InternalSCC scc ;
4- private final java . util . BitSet answer ;
7+ private final boolean [] answer ;
58
69 private boolean hasCalledSatisfiable = false ;
710 private boolean existsAnswer = false ;
811
912 public TwoSAT (int n ) {
1013 this .n = n ;
1114 this .scc = new InternalSCC (2 * n );
12- this .answer = new java . util . BitSet ( n ) ;
15+ this .answer = new boolean [ n ] ;
1316 }
1417
1518 public void addClause (int x , boolean f , int y , boolean g ) {
@@ -30,12 +33,12 @@ public boolean satisfiable() {
3033 int [] ids = scc .ids ();
3134 for (int i = 0 ; i < n ; i ++) {
3235 if (ids [i << 1 | 0 ] == ids [i << 1 | 1 ]) return existsAnswer = false ;
33- answer . set ( i , ids [i << 1 | 0 ] < ids [i << 1 | 1 ]) ;
36+ answer [ i ] = ids [i << 1 | 0 ] < ids [i << 1 | 1 ];
3437 }
3538 return existsAnswer = true ;
3639 }
3740
38- public java . util . BitSet answer () {
41+ public boolean [] answer () {
3942 if (!hasCalledSatisfiable ) {
4043 throw new UnsupportedOperationException (
4144 "Call TwoSAT#satisfiable at least once before TwoSAT#answer."
You can’t perform that action at this time.
0 commit comments