-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbitset.java
More file actions
42 lines (35 loc) · 1.02 KB
/
bitset.java
File metadata and controls
42 lines (35 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class bitset {
public static void main(String[] args) {
Scanner get = new Scanner(System.in);
int n = get.nextInt();
int m = get.nextInt();
BitSet b1 = new BitSet(n);
BitSet b2 = new BitSet(n);
BitSet[] bitset = new BitSet[3];
bitset[1] = b1;
bitset[2] = b2;
while ( 0 < m-- ) {
String op = get.next();
int x = get.nextInt();
int y = get.nextInt();
switch (op) {
case "AND":
bitset[x].and(bitset[y]);
break;
case "OR":
bitset[x].or(bitset[y]);
break;
case "XOR":
bitset[x].xor(bitset[y]);
break;
case "FLIP":
bitset[x].flip(y);
break;
case "SET":
bitset[x].set(y);
}
System.out.printf("%d %d%n", b1.cardinality(), b2.cardinality());
}
}
}