- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava BitSet.java
More file actions
Latest commit
24 lines (24 loc) · 622 Bytes
/
Copy pathJava BitSet.java
File metadata and controls
24 lines (24 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
importjava.util.*;
classSolution {
publicstaticvoidmain(String[] args) {
Scannercin=newScanner(System.in);
intn=cin.nextInt(),m=cin.nextInt();
BitSet[] b={newBitSet(n),newBitSet(n)};
for(inti=0;i<m;i++){
Strings=cin.next();
intx=cin.nextInt(),y=cin.nextInt();
if(s.equals("AND")){
b[x-1].and(b[y-1]);
}elseif(s.equals("OR")){
b[x-1].or(b[y-1]);
}elseif(s.equals("XOR")){
b[x-1].xor(b[y-1]);
}elseif(s.equals("FLIP")){
b[x-1].flip(y);
}elseif(s.equals("SET")){
b[x-1].set(y);
}
System.out.println(b[0].cardinality()+" "+b[1].cardinality());
}
}
}