The document discusses using bitwise operators and dynamic programming to solve problems efficiently. It provides examples of using bitwise OR, AND, XOR operators to add, remove and check for elements in a set represented as a bitmask. It then describes several problems involving bitmasks and dynamic programming including finding the number of possible paths in a graph and the maximum score in a traveling salesman problem. The examples demonstrate how bitwise operators can be used to optimize set operations and dynamic programming can reduce exponential time complexity problems to polynomial time.
3. Bitwise Operator
• A | B => A or B
• A & B => A and B
• A ^ B => A xor B
• A = 1001, B = 0101
• A | B = 1101, A & B = 0001, A ^ B = 1100
• ~A => ones complement of A =>
• A << x => left shift A as x
• A >> x => right shift A as x
• A = 00110101
• ~A = 11001010, A << 2 = 11010100, A >> 2 = 00001101
BitwiseDP 3
4. • S M .
• add x: S x . x
• remove x: S x . x
• check x: S x 1, 0
• toggle x: S x x , x
• all: S {1, 2, ..., 20} .
• empty: S .
• 1 ≤ x ≤ 20
• 1 ≤ M ≤ 3,000,000
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
4