File tree 1 file changed +45
-0
lines changed
Basics Java/src/Practice/Problems
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .*;
2
+ import java .util .*;
3
+ import java .text .*;
4
+ import java .math .*;
5
+ import java .util .regex .*;
6
+
7
+ public class Solution {
8
+
9
+ public static void main (String [] args )
10
+ {
11
+ /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
12
+ Scanner get = new Scanner (System .in );
13
+ int n = get .nextInt ();
14
+ int m = get .nextInt ();
15
+ BitSet b1 = new BitSet (n );
16
+ BitSet b2 = new BitSet (n );
17
+ BitSet [] bitset = new BitSet [3 ];
18
+ bitset [1 ] = b1 ;
19
+ bitset [2 ] = b2 ;
20
+ while ( 0 < m -- )
21
+ {
22
+ String op = get .next ();
23
+ int x = get .nextInt ();
24
+ int y = get .nextInt ();
25
+ switch (op )
26
+ {
27
+ case "AND" :
28
+ bitset [x ].and (bitset [y ]);
29
+ break ;
30
+ case "OR" :
31
+ bitset [x ].or (bitset [y ]);
32
+ break ;
33
+ case "XOR" :
34
+ bitset [x ].xor (bitset [y ]);
35
+ break ;
36
+ case "FLIP" :
37
+ bitset [x ].flip (y );
38
+ break ;
39
+ case "SET" :
40
+ bitset [x ].set (y );
41
+ }
42
+ System .out .printf ("%d %d%n" , b1 .cardinality (), b2 .cardinality ());
43
+ }
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments