- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
Latest commit
63 lines (60 loc) · 1.73 KB
/
Copy pathSolution.java
File metadata and controls
63 lines (60 loc) · 1.73 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
importjava.io.*;
importjava.util.*;
importjava.text.*;
importjava.math.*;
importjava.util.regex.*;
publicclassSolution {
publicstaticvoidmain(String[] args) {
Scannerscan = newScanner(System.in);
intN = scan.nextInt();
intM = scan.nextInt();
BitSetB1 = newBitSet(N);
BitSetB2 = newBitSet(N);
while (M-- > 0) {
Stringstr = scan.next();
inta = scan.nextInt();
intb = scan.nextInt();
switch (str) {
case"AND":
if (a == 1) {
B1.and(B2);
} else {
B2.and(B1);
}
break;
case"OR":
if (a == 1) {
B1.or(B2);
} else {
B2.or(B1);
}
break;
case"XOR":
if (a == 1) {
B1.xor(B2);
} else {
B2.xor(B1);
}
break;
case"FLIP":
if (a == 1) {
B1.flip(b);
} else {
B2.flip(b);
}
break;
case"SET":
if (a == 1) {
B1.set(b);
} else {
B2.set(b);
}
break;
default:
break;
}
System.out.println(B1.cardinality() + " " + B2.cardinality());
}
scan.close();
}
}