SlideShare a Scribd company logo
1 of 104
Download to read offline
Bitwise DP
(Acka)
Bitwise Operator
BitwiseDP 2
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
• 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
• bool exist [21]
• exist[i]: i true, false
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
5
• .
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
6
• .
• stat = 50 = 0….000000000000000110010(2)
• stat: {2, 5, 6}
• i-1 : i /
• .
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
7
• add x
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
8
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
9
…01010001(2)
…01011001(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
10
…01010001(2)
+ …00001000(2)
…01011001(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
11
…01011001(2)
+ …00001000(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
12
…01011001(2)
+ …00001000(2)
…01100001(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
13
…0101?001(2)
or …00001000(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
14
…0101?001(2)
or …00001000(2)
…0101?001(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
15
…0101?001(2)
or …00001000(2)
…0101?001(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
16
…0101?001(2)
or …00001000(2)
…0101?001(2)
1|0 = 1
0|0 = 0
0 or
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
17
…0101?001(2)
or …00001000(2)
…0101?001(2)
• add 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
18
…0101?001(2)
or …00001000(2)
…01011001(2)
1|1 = 1
0|1 = 1
1 or 1
• add x = stat | (1 << (x – 1))
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
19
…0101?001(2)
or …00001000(2)
…01011001(2)
• remove 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
20
…0101?001(2)
• remove 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
21
…0101?001(2)
& …11110111(2)
…0101?001(2)
• remove 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
22
…0101?001(2)
& …11110111(2)
…0101?001(2)
• remove 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
23
…0101?001(2)
& …11110111(2)
…0101?001(2)
1&1 = 1
0&1 = 0
1 and
• remove 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
24
…0101?001(2)
& …11110111(2)
…0101?001(2)
• remove 4
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
25
…0101?001(2)
& …11110111(2)
…01010001(2)
0&0 = 0
1&0 = 0
0 and 0
• remove x = stat & ~(1 << (x – 1))
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
26
…0101?001(2)
& …11110111(2)
…01010001(2)
• bit[x] = 2x-1
• add: stat |= bit[x]
• remove: stat &= ~bit[x]
• check: stat & bit[x]
• toggle: stat ^= bit[x]
• all: stat = bit[21] - 1
• empty: stat = 0
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
27
• C/C++:
https://gist.github.com/Acka1357/61f2990267345c21319bbf4fb79fe5a2
• Java:
https://gist.github.com/Acka1357/2c243480be1edca69968a7ad300279cf
BitwiseDP
Problem: https://www.acmicpc.net/problem/11723
28
•
• N 0 9
• (0 .)
• 1 ≤ N ≤	100
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
29
•
• D[i][j]: i j
• D[i][j] = D[i – 1][j – 1] + D[i – 1][j + 1]
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
30
•
• D[i][j]: i j
• D[i][j] = D[i – 1][j – 1] + D[i – 1][j + 1]
• + 0 ~ 9
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
31
• D[i][j][use0][use1][use2]…[use9]:
i j
use0, use1, use2 .. use9
(use0, use1 … use9 = 0 or 1)
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
32
• D[i][j][use0][use1][use2]…[use9]:
i j
use0, use1, use2 .. use9
(use0, use1 … use9 = 0 or 1)
• [use0][use1][use2]…[use9]: 2 * 2 * 2 * … * 2
=> 210
=> 0000000000(2) ~ 1111111111(2)
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
33
• D[i][j][used]: i j
used
• used: 0000000000(2) ~ 1111111111(2) => 210
• used k(0~9) bit: k
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
34
• D[i][j][used]: i j
used
• used: 0000000000(2) ~ 1111111111(2) => 210
• used k(0~9) bit: k
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
used: 101 = 0001100101(2)
5 0
8
35
• D[i][j][used]: i j
used
• used .
• D[i][j - 1][used] -> D[i + 1][j][used | 2j]
• D[i][j + 1][used] -> D[i + 1][j][used | 2j]
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
36
• : ∑ 𝐷 𝑁 𝑖 [1023]-
./0
• N (used == 1111111111(2))
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
37
• : O(N * 10 * 210)
• * *
• 1 ≤ N ≤	100
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
38
• C/C++:
https://gist.github.com/Acka1357/ba689997d73246d77a8ccc33f876073f
• Java:
https://gist.github.com/Acka1357/1d65d7af446ce436b48b80a36386e108
BitwiseDP
Problem: https://www.acmicpc.net/problem/1562
39
• 1 N .
• N
• . ( )
•
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 40
•
• *
* …
• N * (N – 1) * (N – 2) * … * 1 => O(N!)
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 41
•
• *
* …
• N * (N – 1) * (N – 2) * … * 1 => O(N!)
• 2 ≤ N ≤ 16
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 42
•
• *
* …
• N * (N – 1) * (N – 2) * … * 1 => O(N!)
• 2 ≤ N ≤ 16
• 16! => 20,922,789,888,000
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 43
• 1 -> 2 -> 3 -> 4 -> ?
• 1 -> 3 -> 2 -> 4 -> ?
• : 1, 2, 3, 4 4
• : 4
1
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 44
• 1 -> 2 -> 3 -> 4 -> ?
• 1 -> 3 -> 2 -> 4 -> ?
•
• .
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 45
•
•
• /
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 46
•
•
• /
• (1 ) * (2 ) * (3
) * … * (N )
• 2N
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 47
• d[cur][visited]: i
visited
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 48
• d[cur][visited]: i
visited
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP
visited: 101 = 01100101(2)
49
• d[cur][visited]: i
visited
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP
7 1
8
50
visited: 101 = 01100101(2)
• d[cur][visited]: i
visited
• d[cur][visited] + cost[cur][next] -> d[next][visited + 2next]
• 2next : next
• next
• visited & 2next == 0
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 51
• d[cur][visited]
visited cur
d[cur][visited] .
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP
10011010
10011010
10011010
10011010
00011010
10001010
10010010
10011000
min
52
cur visited
2,4,5
2,4,8
2,5,8
4,5,8
cur visited
8
5
4
2
• d[cur][visited]
visited cur
d[cur][visited] .
• visited .
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP
10011010
10011010
10011010
10011010
00011010
10001010
10010010
10011000
min
53
cur visited
2,4,5
2,4,8
2,5,8
4,5,8
cur visited
8
5
4
2
• d[cur][visited]: i
visited
• d[cur][visited] = minpast ∈	visited (d[past][visited – 2cur]
+ cost[past][cur])
• 2cur : cur
• past cur , visited
• visited & 2past == 2past
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 54
•
• ( ) .
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 55
•
• ( ) .
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 56
P1 P2 P3 P4 P5 P6
•
• ( ) .
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 57
P1
P2
P3
P4
P5
P6
• : O(N * N * 2N)
• : O(N * 2N)
• / : O(N)
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 58
• C/C++:
https://gist.github.com/Acka1357/be750aba1f1950f50c93dce7d038752c
https://gist.github.com/Acka1357/2815446354910d6b4ac84164a776b6ee
• Java:
https://gist.github.com/Acka1357/25a34b9ea7e49ad148fe4cfe2fe6143b
Problem: https://www.acmicpc.net/problem/2098
BitwiseDP 59
• N X M
• 2 X 1, 1 X 2
•
• 1 ≤ N, M ≤ 14
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 60
• , .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 61
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
• , 0 .
• (0, 1) (0, 10)
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 62
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
• (0, 1)
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 63
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
• 0 1 .
• 0 , M-1
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 64
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
• status = 20 + 21
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 65
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
0으로부터 한 줄의 상태:
0000000011(2)
• (0, 10)
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 66
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
• status = 20 ( )
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 67
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
0으로부터 한 줄의 상태:
0000000001(2)
• 1 , 0 ,
• 0 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 68
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
0으로부터 한 줄의 상태:
0000000001(2)
• 0 10 ,
• 10 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 69
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
… …
… …
1로부터 ‘한 줄’의 상태:
1000000000(2)
• i-1 0 -> i
• i (i + 1) (i + M) .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 70
0 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
… …
• i , (i – 1)
• (i + M) .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 71
0 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
… …
• i i M
(i – 1) 1, (i + M) 0
.
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 72
0 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
… …
• 12
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 73
0 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
… …
12부터 M칸의 상태:
1111001001(2)
• 12
• 11 , 22 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 74
0 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
… …
12부터 M칸의 상태:
1111001001(2)
• 12
• 12 , 13 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 75
0 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
… …
12부터 M칸의 상태:
1111001001(2)
• 13 M
• 12 M .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 76
0 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
… …
12부터 M칸의 상태:
1111001001(2)
• status >> 1 (or status /= 2)
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 77
0 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
… …
13부터 M칸의 상태:
0111100100(2)
• 13
• 13 , 23 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 78
0 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
… …
12부터 M칸의 상태:
1111001001(2)
• 13
• (13, 14) (13, 23) .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 79
0 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
… …
13부터 M칸의 상태:
0111100100(2)
• (13, 14) (13, 14) .
• 0 1 0 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 80
0 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
… …
13부터 M칸의 상태:
0111100100(2)
• (13, 14) ,
• 14 M .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 81
0 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
… …
13부터 M칸의 상태:
0111100100(2)
• (status >> 1) + 20
• 14 M 14 0
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 82
0 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
… …
14부터 M칸의 상태:
0011110011(2)
• (13, 23) (13, 23) .
• 23 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 83
0 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
… …
13부터 M칸의 상태:
0111100100(2)
• (13, 23) ,
• 14 M .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 84
0 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
… …
13부터 M칸의 상태:
0111100100(2)
• (status >> 1) + 2M-1
• 14 M 23 M-1 .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 85
0 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
… …
14부터 M칸의 상태:
1011110010(2)
• D[i][status]: i – 1 ,
i M status
• 0 ≤	status < 2M
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 86
• i (if (status & 1) == 1)
• d[i + 1][status >> 1] += d[i][status]
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 87
• i (if (status & 1) == 1)
• d[i + 1][status >> 1] += d[i][status]
• i
•
•
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 88
• (if (status & 3) == 0)
• d[i + 1][(status >> 1) + 1] += d[i][status]
• (i (status & 1) == 0)
• d[i + 1][(status >> 1) + 2M-1] += d[i][status]
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 89
• (if (status & 3) == 0)
• d[i + 1][(status >> 1) + 1] += d[i][status]
• (i (status & 1) == 0)
• d[i + 1][(status >> 1) + 2M-1] += d[i][status]
• , i .
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 90
• d[i + 1][(status >> 1)] += d[i][status]
• if (status & 1) == 1
• d[i + 1][(status >> 1) + 1] += d[i][status]
• if (status & 3) == 0, and (i % M) != M – 1
• d[i + 1][(status >> 1) + 2M-1] += d[i][status]
• if (status & 1) == 0
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 91
• : d[N * M][0]
• N * M (N * M – 1) ,
• N * M
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 92
• : O(N * M * 2M)
• : O(N * M)
• : O(2M)
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 93
• C/C++:
https://gist.github.com/Acka1357/473f67f678c484b19e5d5daabde7522c
• Java:
https://gist.github.com/Acka1357/3406495ff3597161c4245d9989dc3fa7
Problem: https://www.acmicpc.net/problem/1648
BitwiseDP 94
• N X M
• 2 X 1, 1 X 2
• .
• .
•
• 1 ≤ N, M ≤ 14
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 95
• ==
• , .
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 96
• ==
• , .
• , .
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 97
• D[i][status]: i – 1 ( ) ,
i M status
• 0 ≤	status < 2M
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 98
• i (if (status & 1) == 1)
• d[i + 1][status >> 1] <- d[i][status]
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 99
• i (if (status & 1) == 1)
• d[i + 1][status >> 1] <- d[i][status]
• i
• d[i + 1][status >> 1] <- d[i][status]
• d[i + 1][(status >> 1) + 1] += d[i][status] ( )
• d[i + 1][(status >> 1) + 2M-1] += d[i][status] ( )
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 100
• d[i + 1][(status >> 1)] <- d[i][status]
• always possible
• d[i + 1][(status >> 1) + 1] += d[i][status]
• if (status & 3) == 0, and (i % M) != M – 1
• d[i + 1][(status >> 1) + 2M-1] += d[i][status]
• if (status & 1) == 0
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 101
• : d[N * M][0]
• N * M (N * M – 1) ( ) ,
• N * M
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 102
• : O(N * M * 2M)
• : O(N * M)
• : O(2M)
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 103
• C/C++:
https://gist.github.com/Acka1357/99cd03e1d98611f02840ab9708052c99
• Java:
https://gist.github.com/Acka1357/6d5dbdcc1528957a2896a703f6fa796c
Problem: https://www.acmicpc.net/problem/1657
BitwiseDP 104

More Related Content

What's hot

The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196Mahmoud Samir Fayed
 
Playing with camera preview buffers on BlackBerry 10
Playing with camera preview buffers on BlackBerry 10Playing with camera preview buffers on BlackBerry 10
Playing with camera preview buffers on BlackBerry 10Raimon Ràfols
 
2019-ME-37(NMC).docx
2019-ME-37(NMC).docx2019-ME-37(NMC).docx
2019-ME-37(NMC).docxArhamQadeer
 
apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...
apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...
apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...apidays
 

What's hot (7)

Gilat_ch03.pdf
Gilat_ch03.pdfGilat_ch03.pdf
Gilat_ch03.pdf
 
The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196
 
Gilat_ch02.pdf
Gilat_ch02.pdfGilat_ch02.pdf
Gilat_ch02.pdf
 
Prelude to halide_public
Prelude to halide_publicPrelude to halide_public
Prelude to halide_public
 
Playing with camera preview buffers on BlackBerry 10
Playing with camera preview buffers on BlackBerry 10Playing with camera preview buffers on BlackBerry 10
Playing with camera preview buffers on BlackBerry 10
 
2019-ME-37(NMC).docx
2019-ME-37(NMC).docx2019-ME-37(NMC).docx
2019-ME-37(NMC).docx
 
apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...
apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...
apidays LIVE Australia - Strangling the monolith with a reactive GraphQL gate...
 

Similar to 알고리즘 연합캠프 세미나 1-B (Bitwise DP)

Windows kernel debugging workshop in florida
Windows kernel debugging   workshop in floridaWindows kernel debugging   workshop in florida
Windows kernel debugging workshop in floridaSisimon Soman
 
Windows debugging sisimon
Windows debugging   sisimonWindows debugging   sisimon
Windows debugging sisimonSisimon Soman
 
DEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouse
DEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouseDEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouse
DEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouseFelipe Prado
 
Visual thinking colin_ware_lectures_2013_3_findability
Visual thinking colin_ware_lectures_2013_3_findabilityVisual thinking colin_ware_lectures_2013_3_findability
Visual thinking colin_ware_lectures_2013_3_findabilityElsa von Licy
 
Reverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machinesReverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machinesSmartDec
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...pycontw
 
OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...
OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...
OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...Chanwoo Choi
 
[Name Sponged] Consulting Project
[Name Sponged] Consulting Project[Name Sponged] Consulting Project
[Name Sponged] Consulting ProjectRyan Elder
 
TC74VHCT244AF PSpice Model (Free SPICE Model)
TC74VHCT244AF PSpice Model (Free SPICE Model)TC74VHCT244AF PSpice Model (Free SPICE Model)
TC74VHCT244AF PSpice Model (Free SPICE Model)Tsuyoshi Horigome
 
20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~
20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~
20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~耕二 阿部
 
TC74VHCT244AFT PSpice Model (Free SPICE Model)
TC74VHCT244AFT PSpice Model (Free SPICE Model)TC74VHCT244AFT PSpice Model (Free SPICE Model)
TC74VHCT244AFT PSpice Model (Free SPICE Model)Tsuyoshi Horigome
 
TC74VHCT244AFW PSpice Model (Free SPICE Model)
TC74VHCT244AFW PSpice Model (Free SPICE Model)TC74VHCT244AFW PSpice Model (Free SPICE Model)
TC74VHCT244AFW PSpice Model (Free SPICE Model)Tsuyoshi Horigome
 

Similar to 알고리즘 연합캠프 세미나 1-B (Bitwise DP) (20)

Windows kernel debugging workshop in florida
Windows kernel debugging   workshop in floridaWindows kernel debugging   workshop in florida
Windows kernel debugging workshop in florida
 
Geidai Open Workshop 2009
Geidai Open Workshop 2009Geidai Open Workshop 2009
Geidai Open Workshop 2009
 
chris-bake.pdf
chris-bake.pdfchris-bake.pdf
chris-bake.pdf
 
Windows debugging sisimon
Windows debugging   sisimonWindows debugging   sisimon
Windows debugging sisimon
 
DEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouse
DEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouseDEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouse
DEF CON 23 - Yaniv Balmas and Lior Oppenheim - key logger-video mouse
 
Debugging TV Frame 0x02
Debugging TV Frame 0x02Debugging TV Frame 0x02
Debugging TV Frame 0x02
 
ch02.ppt
ch02.pptch02.ppt
ch02.ppt
 
Debugging TV Frame 0x24
Debugging TV Frame 0x24Debugging TV Frame 0x24
Debugging TV Frame 0x24
 
Visual thinking colin_ware_lectures_2013_3_findability
Visual thinking colin_ware_lectures_2013_3_findabilityVisual thinking colin_ware_lectures_2013_3_findability
Visual thinking colin_ware_lectures_2013_3_findability
 
Reverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machinesReverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machines
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...
 
OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...
OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...
OpenIot & ELC Europe 2016 Berlin - How to develop the ARM 64bit board, Samsun...
 
crack satellite
crack satellite crack satellite
crack satellite
 
[Name Sponged] Consulting Project
[Name Sponged] Consulting Project[Name Sponged] Consulting Project
[Name Sponged] Consulting Project
 
eel6935_ch2.pdf
eel6935_ch2.pdfeel6935_ch2.pdf
eel6935_ch2.pdf
 
TC74VHCT244AF PSpice Model (Free SPICE Model)
TC74VHCT244AF PSpice Model (Free SPICE Model)TC74VHCT244AF PSpice Model (Free SPICE Model)
TC74VHCT244AF PSpice Model (Free SPICE Model)
 
20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~
20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~
20201029 モデルベース開発モーター制御編~C言語とSimulinkの文法記述を比較する~
 
TC74VHCT244AFT PSpice Model (Free SPICE Model)
TC74VHCT244AFT PSpice Model (Free SPICE Model)TC74VHCT244AFT PSpice Model (Free SPICE Model)
TC74VHCT244AFT PSpice Model (Free SPICE Model)
 
TC74VHCT244AFW PSpice Model (Free SPICE Model)
TC74VHCT244AFW PSpice Model (Free SPICE Model)TC74VHCT244AFW PSpice Model (Free SPICE Model)
TC74VHCT244AFW PSpice Model (Free SPICE Model)
 
IPv6 Basics
IPv6 BasicsIPv6 Basics
IPv6 Basics
 

More from HYUNJEONG KIM

알고리즘 연합캠프 세미나 3-B (LCA)
알고리즘 연합캠프 세미나 3-B (LCA)알고리즘 연합캠프 세미나 3-B (LCA)
알고리즘 연합캠프 세미나 3-B (LCA)HYUNJEONG KIM
 
알고리즘 연합캠프 세미나 3-C (C++11 and ETC)
알고리즘 연합캠프 세미나 3-C (C++11 and ETC)알고리즘 연합캠프 세미나 3-C (C++11 and ETC)
알고리즘 연합캠프 세미나 3-C (C++11 and ETC)HYUNJEONG KIM
 
알고리즘 연합캠프 세미나 2-C (Segment Tree)
알고리즘 연합캠프 세미나 2-C (Segment Tree)알고리즘 연합캠프 세미나 2-C (Segment Tree)
알고리즘 연합캠프 세미나 2-C (Segment Tree)HYUNJEONG KIM
 
알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)
알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)
알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)HYUNJEONG KIM
 
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)HYUNJEONG KIM
 
알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)
알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)
알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)HYUNJEONG KIM
 
shake! 2017 본선문제 풀이
shake! 2017 본선문제 풀이shake! 2017 본선문제 풀이
shake! 2017 본선문제 풀이HYUNJEONG KIM
 
shake! 2017 예선 문제 풀이
shake! 2017 예선 문제 풀이shake! 2017 예선 문제 풀이
shake! 2017 예선 문제 풀이HYUNJEONG KIM
 
shake! 2016 예선 문제 풀이
shake! 2016 예선 문제 풀이shake! 2016 예선 문제 풀이
shake! 2016 예선 문제 풀이HYUNJEONG KIM
 

More from HYUNJEONG KIM (9)

알고리즘 연합캠프 세미나 3-B (LCA)
알고리즘 연합캠프 세미나 3-B (LCA)알고리즘 연합캠프 세미나 3-B (LCA)
알고리즘 연합캠프 세미나 3-B (LCA)
 
알고리즘 연합캠프 세미나 3-C (C++11 and ETC)
알고리즘 연합캠프 세미나 3-C (C++11 and ETC)알고리즘 연합캠프 세미나 3-C (C++11 and ETC)
알고리즘 연합캠프 세미나 3-C (C++11 and ETC)
 
알고리즘 연합캠프 세미나 2-C (Segment Tree)
알고리즘 연합캠프 세미나 2-C (Segment Tree)알고리즘 연합캠프 세미나 2-C (Segment Tree)
알고리즘 연합캠프 세미나 2-C (Segment Tree)
 
알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)
알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)
알고리즘 연합캠프 세미나 1-A (Multi Dimension Segment/Fenwick Tree)
 
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
 
알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)
알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)
알고리즘 연합캠프 세미나 1-D (Knapsack, Tree DP)
 
shake! 2017 본선문제 풀이
shake! 2017 본선문제 풀이shake! 2017 본선문제 풀이
shake! 2017 본선문제 풀이
 
shake! 2017 예선 문제 풀이
shake! 2017 예선 문제 풀이shake! 2017 예선 문제 풀이
shake! 2017 예선 문제 풀이
 
shake! 2016 예선 문제 풀이
shake! 2016 예선 문제 풀이shake! 2016 예선 문제 풀이
shake! 2016 예선 문제 풀이
 

Recently uploaded

Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 

Recently uploaded (20)

🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 

알고리즘 연합캠프 세미나 1-B (Bitwise DP)

  • 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
  • 5. • bool exist [21] • exist[i]: i true, false BitwiseDP Problem: https://www.acmicpc.net/problem/11723 5
  • 7. • . • stat = 50 = 0….000000000000000110010(2) • stat: {2, 5, 6} • i-1 : i / • . BitwiseDP Problem: https://www.acmicpc.net/problem/11723 7
  • 8. • add x BitwiseDP Problem: https://www.acmicpc.net/problem/11723 8
  • 9. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 9 …01010001(2) …01011001(2)
  • 10. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 10 …01010001(2) + …00001000(2) …01011001(2)
  • 11. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 11 …01011001(2) + …00001000(2)
  • 12. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 12 …01011001(2) + …00001000(2) …01100001(2)
  • 13. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 13 …0101?001(2) or …00001000(2)
  • 14. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 14 …0101?001(2) or …00001000(2) …0101?001(2)
  • 15. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 15 …0101?001(2) or …00001000(2) …0101?001(2)
  • 16. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 16 …0101?001(2) or …00001000(2) …0101?001(2) 1|0 = 1 0|0 = 0 0 or
  • 17. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 17 …0101?001(2) or …00001000(2) …0101?001(2)
  • 18. • add 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 18 …0101?001(2) or …00001000(2) …01011001(2) 1|1 = 1 0|1 = 1 1 or 1
  • 19. • add x = stat | (1 << (x – 1)) BitwiseDP Problem: https://www.acmicpc.net/problem/11723 19 …0101?001(2) or …00001000(2) …01011001(2)
  • 20. • remove 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 20 …0101?001(2)
  • 21. • remove 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 21 …0101?001(2) & …11110111(2) …0101?001(2)
  • 22. • remove 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 22 …0101?001(2) & …11110111(2) …0101?001(2)
  • 23. • remove 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 23 …0101?001(2) & …11110111(2) …0101?001(2) 1&1 = 1 0&1 = 0 1 and
  • 24. • remove 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 24 …0101?001(2) & …11110111(2) …0101?001(2)
  • 25. • remove 4 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 25 …0101?001(2) & …11110111(2) …01010001(2) 0&0 = 0 1&0 = 0 0 and 0
  • 26. • remove x = stat & ~(1 << (x – 1)) BitwiseDP Problem: https://www.acmicpc.net/problem/11723 26 …0101?001(2) & …11110111(2) …01010001(2)
  • 27. • bit[x] = 2x-1 • add: stat |= bit[x] • remove: stat &= ~bit[x] • check: stat & bit[x] • toggle: stat ^= bit[x] • all: stat = bit[21] - 1 • empty: stat = 0 BitwiseDP Problem: https://www.acmicpc.net/problem/11723 27
  • 29. • • N 0 9 • (0 .) • 1 ≤ N ≤ 100 BitwiseDP Problem: https://www.acmicpc.net/problem/1562 29
  • 30. • • D[i][j]: i j • D[i][j] = D[i – 1][j – 1] + D[i – 1][j + 1] BitwiseDP Problem: https://www.acmicpc.net/problem/1562 30
  • 31. • • D[i][j]: i j • D[i][j] = D[i – 1][j – 1] + D[i – 1][j + 1] • + 0 ~ 9 BitwiseDP Problem: https://www.acmicpc.net/problem/1562 31
  • 32. • D[i][j][use0][use1][use2]…[use9]: i j use0, use1, use2 .. use9 (use0, use1 … use9 = 0 or 1) BitwiseDP Problem: https://www.acmicpc.net/problem/1562 32
  • 33. • D[i][j][use0][use1][use2]…[use9]: i j use0, use1, use2 .. use9 (use0, use1 … use9 = 0 or 1) • [use0][use1][use2]…[use9]: 2 * 2 * 2 * … * 2 => 210 => 0000000000(2) ~ 1111111111(2) BitwiseDP Problem: https://www.acmicpc.net/problem/1562 33
  • 34. • D[i][j][used]: i j used • used: 0000000000(2) ~ 1111111111(2) => 210 • used k(0~9) bit: k BitwiseDP Problem: https://www.acmicpc.net/problem/1562 34
  • 35. • D[i][j][used]: i j used • used: 0000000000(2) ~ 1111111111(2) => 210 • used k(0~9) bit: k BitwiseDP Problem: https://www.acmicpc.net/problem/1562 used: 101 = 0001100101(2) 5 0 8 35
  • 36. • D[i][j][used]: i j used • used . • D[i][j - 1][used] -> D[i + 1][j][used | 2j] • D[i][j + 1][used] -> D[i + 1][j][used | 2j] BitwiseDP Problem: https://www.acmicpc.net/problem/1562 36
  • 37. • : ∑ 𝐷 𝑁 𝑖 [1023]- ./0 • N (used == 1111111111(2)) BitwiseDP Problem: https://www.acmicpc.net/problem/1562 37
  • 38. • : O(N * 10 * 210) • * * • 1 ≤ N ≤ 100 BitwiseDP Problem: https://www.acmicpc.net/problem/1562 38
  • 40. • 1 N . • N • . ( ) • Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 40
  • 41. • • * * … • N * (N – 1) * (N – 2) * … * 1 => O(N!) Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 41
  • 42. • • * * … • N * (N – 1) * (N – 2) * … * 1 => O(N!) • 2 ≤ N ≤ 16 Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 42
  • 43. • • * * … • N * (N – 1) * (N – 2) * … * 1 => O(N!) • 2 ≤ N ≤ 16 • 16! => 20,922,789,888,000 Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 43
  • 44. • 1 -> 2 -> 3 -> 4 -> ? • 1 -> 3 -> 2 -> 4 -> ? • : 1, 2, 3, 4 4 • : 4 1 Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 44
  • 45. • 1 -> 2 -> 3 -> 4 -> ? • 1 -> 3 -> 2 -> 4 -> ? • • . Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 45
  • 47. • • • / • (1 ) * (2 ) * (3 ) * … * (N ) • 2N Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 47
  • 48. • d[cur][visited]: i visited Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 48
  • 49. • d[cur][visited]: i visited Problem: https://www.acmicpc.net/problem/2098 BitwiseDP visited: 101 = 01100101(2) 49
  • 50. • d[cur][visited]: i visited Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 7 1 8 50 visited: 101 = 01100101(2)
  • 51. • d[cur][visited]: i visited • d[cur][visited] + cost[cur][next] -> d[next][visited + 2next] • 2next : next • next • visited & 2next == 0 Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 51
  • 52. • d[cur][visited] visited cur d[cur][visited] . Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 10011010 10011010 10011010 10011010 00011010 10001010 10010010 10011000 min 52 cur visited 2,4,5 2,4,8 2,5,8 4,5,8 cur visited 8 5 4 2
  • 53. • d[cur][visited] visited cur d[cur][visited] . • visited . Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 10011010 10011010 10011010 10011010 00011010 10001010 10010010 10011000 min 53 cur visited 2,4,5 2,4,8 2,5,8 4,5,8 cur visited 8 5 4 2
  • 54. • d[cur][visited]: i visited • d[cur][visited] = minpast ∈ visited (d[past][visited – 2cur] + cost[past][cur]) • 2cur : cur • past cur , visited • visited & 2past == 2past Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 54
  • 55. • • ( ) . Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 55
  • 56. • • ( ) . Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 56 P1 P2 P3 P4 P5 P6
  • 57. • • ( ) . Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 57 P1 P2 P3 P4 P5 P6
  • 58. • : O(N * N * 2N) • : O(N * 2N) • / : O(N) Problem: https://www.acmicpc.net/problem/2098 BitwiseDP 58
  • 60. • N X M • 2 X 1, 1 X 2 • • 1 ≤ N, M ≤ 14 Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 60
  • 61. • , . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 61 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … …
  • 62. • , 0 . • (0, 1) (0, 10) Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 62 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … …
  • 63. • (0, 1) Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 63 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … …
  • 64. • 0 1 . • 0 , M-1 Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … …
  • 65. • status = 20 + 21 Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 65 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … … 0으로부터 한 줄의 상태: 0000000011(2)
  • 66. • (0, 10) Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 66 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … …
  • 67. • status = 20 ( ) Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 67 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … … 0으로부터 한 줄의 상태: 0000000001(2)
  • 68. • 1 , 0 , • 0 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 68 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … … 0으로부터 한 줄의 상태: 0000000001(2)
  • 69. • 0 10 , • 10 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 69 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 … … … … 1로부터 ‘한 줄’의 상태: 1000000000(2)
  • 70. • i-1 0 -> i • i (i + 1) (i + M) . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 70 0 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 … …
  • 71. • i , (i – 1) • (i + M) . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 71 0 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 … …
  • 72. • i i M (i – 1) 1, (i + M) 0 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 72 0 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 … …
  • 73. • 12 Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 73 0 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 … … 12부터 M칸의 상태: 1111001001(2)
  • 74. • 12 • 11 , 22 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 74 0 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 … … 12부터 M칸의 상태: 1111001001(2)
  • 75. • 12 • 12 , 13 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 75 0 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 … … 12부터 M칸의 상태: 1111001001(2)
  • 76. • 13 M • 12 M . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 76 0 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 … … 12부터 M칸의 상태: 1111001001(2)
  • 77. • status >> 1 (or status /= 2) Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 77 0 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 … … 13부터 M칸의 상태: 0111100100(2)
  • 78. • 13 • 13 , 23 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 78 0 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 … … 12부터 M칸의 상태: 1111001001(2)
  • 79. • 13 • (13, 14) (13, 23) . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 79 0 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 … … 13부터 M칸의 상태: 0111100100(2)
  • 80. • (13, 14) (13, 14) . • 0 1 0 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 80 0 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 … … 13부터 M칸의 상태: 0111100100(2)
  • 81. • (13, 14) , • 14 M . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 81 0 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 … … 13부터 M칸의 상태: 0111100100(2)
  • 82. • (status >> 1) + 20 • 14 M 14 0 Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 82 0 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 … … 14부터 M칸의 상태: 0011110011(2)
  • 83. • (13, 23) (13, 23) . • 23 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 83 0 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 … … 13부터 M칸의 상태: 0111100100(2)
  • 84. • (13, 23) , • 14 M . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 84 0 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 … … 13부터 M칸의 상태: 0111100100(2)
  • 85. • (status >> 1) + 2M-1 • 14 M 23 M-1 . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 85 0 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 … … 14부터 M칸의 상태: 1011110010(2)
  • 86. • D[i][status]: i – 1 , i M status • 0 ≤ status < 2M Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 86
  • 87. • i (if (status & 1) == 1) • d[i + 1][status >> 1] += d[i][status] Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 87
  • 88. • i (if (status & 1) == 1) • d[i + 1][status >> 1] += d[i][status] • i • • Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 88
  • 89. • (if (status & 3) == 0) • d[i + 1][(status >> 1) + 1] += d[i][status] • (i (status & 1) == 0) • d[i + 1][(status >> 1) + 2M-1] += d[i][status] Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 89
  • 90. • (if (status & 3) == 0) • d[i + 1][(status >> 1) + 1] += d[i][status] • (i (status & 1) == 0) • d[i + 1][(status >> 1) + 2M-1] += d[i][status] • , i . Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 90
  • 91. • d[i + 1][(status >> 1)] += d[i][status] • if (status & 1) == 1 • d[i + 1][(status >> 1) + 1] += d[i][status] • if (status & 3) == 0, and (i % M) != M – 1 • d[i + 1][(status >> 1) + 2M-1] += d[i][status] • if (status & 1) == 0 Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 91
  • 92. • : d[N * M][0] • N * M (N * M – 1) , • N * M Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 92
  • 93. • : O(N * M * 2M) • : O(N * M) • : O(2M) Problem: https://www.acmicpc.net/problem/1648 BitwiseDP 93
  • 95. • N X M • 2 X 1, 1 X 2 • . • . • • 1 ≤ N, M ≤ 14 Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 95
  • 96. • == • , . Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 96
  • 97. • == • , . • , . Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 97
  • 98. • D[i][status]: i – 1 ( ) , i M status • 0 ≤ status < 2M Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 98
  • 99. • i (if (status & 1) == 1) • d[i + 1][status >> 1] <- d[i][status] Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 99
  • 100. • i (if (status & 1) == 1) • d[i + 1][status >> 1] <- d[i][status] • i • d[i + 1][status >> 1] <- d[i][status] • d[i + 1][(status >> 1) + 1] += d[i][status] ( ) • d[i + 1][(status >> 1) + 2M-1] += d[i][status] ( ) Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 100
  • 101. • d[i + 1][(status >> 1)] <- d[i][status] • always possible • d[i + 1][(status >> 1) + 1] += d[i][status] • if (status & 3) == 0, and (i % M) != M – 1 • d[i + 1][(status >> 1) + 2M-1] += d[i][status] • if (status & 1) == 0 Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 101
  • 102. • : d[N * M][0] • N * M (N * M – 1) ( ) , • N * M Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 102
  • 103. • : O(N * M * 2M) • : O(N * M) • : O(2M) Problem: https://www.acmicpc.net/problem/1657 BitwiseDP 103