You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Integer N = scnr.nextInt(); Integer M = scnr.nextInt(); BitSet[] b = new BitSet[] {new BitSet(N), new BitSet(N)}; for (int i = 0; i < M; i++) { String op = scnr.next(); Integer p1 = scnr.nextInt(); Integer p2 = scnr.nextInt(); if (op.equals("AND")) { b[p1-1].and(b[p2-1]); } else if (op.equals("OR")) { b[p1-1].or(b[p2-1]); } else if (op.equals("XOR")) { b[p1-1].xor(b[p2-1]); } else if (op.equals("FLIP")) { b[p1-1].flip(p2); } else if (op.equals("SET")) { b[p1-1].set(p2); } System.out.printf("%d %d\n", b[0].cardinality(), b[1].cardinality()); } scnr.close(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Java BitSet
You are viewing a single comment's thread. Return to all comments →