際際滷

際際滷Share a Scribd company logo
By POSTECH Computer Algorithm Team
DP Hard
譟一麹
Contents
POSTECH Computer Algorithm Team
K覯讌  1
覦磯 覓語 0
Bit DP 2
POSTECH Computer Algorithm Team
- 企 碁碁 企れ DPれ 覦一.
- 伎覲企 企れ, れ  DPれ 給!
- 蠏碁Μ螻 (螳)襷 蟲 蟆 , 旧 襷れ企企  豢ロ 覓語れ 襷朱, 譯殊蠍 覦.
螳
POSTECH Computer Algorithm Team
- 蠍磯蓋朱 DP覓語れ 危伎  蠏碁.
- 蠏碁Μ螻 れ  豢ロ 覓語れ,  譴 襯 螻襯企 蟆曙郁 襷給.(  螳,  螳 )
- 危伎 蠍 覓語,  覓語襯 蠍    覓語螳 覦 蟆曙郁 給.
- 蠏碁 企  覓語襯 伎伎 旧 讌 ロ  給.
- 企蟆 ロ企 れ 磯手覃 れ 旧 襷れ企企  襷れ企  給.
れ ?
DP Hard
POSTECH Computer Algorithm Team
-  螳螳 螳讌螻 螳 覦磯 伎   覓願 豕螳 伎 螻, 殊 螳豺 覓願螳  讌れ
覦磯 l , 螳豺  豕螳 襦 讌 螻襯企 覦覯 谿城 覓語
-  譟壱 豕 覓語
- https://www.acmicpc.net/problem/12865 (螳豺  豢ロ 覓語)
- https://algospot.com/judge/problem/read/PACKING (讌れ 豢ロ 覓語)
覦磯 覓語
Knapsack
POSTECH Computer Algorithm Team
Knapsack
1. Brute force
- 螳 覓手唄 蟇磯  蟇磯, 豐 2 螳讌 螳 .
- 2^N螳讌 蟆曙 譴, 譟郁唄(覦磯 覓願)襯 襷譟燕覃伎 螳豺螳   蟆 谿場朱 .
- 螳 蟆曙磯 螳豺  蟲伎 覩襦, 螳覲旧° O(N x 2^N)
- 轟壱蟆, 一も
POSTECH Computer Algorithm Team
Knapsack
2. 覯   覓願 K襯 伎企慨.
- 1覿 i覯讌 覓狩 伎伎 覓願 w襯 襷れり .
- 覓願螳 w螳 る, 1 ~ (i1)覯讌 覓狩 伎伎 w襯 郁, i覯讌 覓狩 讌 蟇磯
- 1 ~ (i-1)覯讌 覓狩 伎伎 w  (i覯讌 覓狩 覓願)襯 襷り, i覯讌 覓狩 覃 .
POSTECH Computer Algorithm Team
Knapsack
讀, 1 ~ i覯讌 覓手唄 伎伎 覓願 w襯 襷れ , 螳豺 豕螳 れ螻 螳 蟲  .
- D[i][w] = max(D[i  1][w], D[i  1][w  (i覯讌 覓手唄 覓願)] + (i覯讌 覓手唄 螳豺))
- 1 <= i <= N, 0 <= w <= K  讌覃 .
-  覯  , D[i][w] 豕螳 旧朱 豢ロ覃 .
- 螳覲旧° O(NK)
Code Explanation
POSTECH Computer Algorithm Team
Code
https://www.acmicpc.net/problem/12865
覯 覦磯
POSTECH Computer Algorithm Team
Knapsack
Q) 覓手唄 螳螳 譟郁襷 襷碁 覃覈襴螳 一. 覃覈襴襯    覦覯 蟾?
POSTECH Computer Algorithm Team
Knapsack
A) D[K] 覦一企 ′ 豢覿 覓語襯   .
- 螳企慨覃, D[i][w] D[i  1][1w] 螳襷 襦 
- 讀, i覯讌 覓狩 螳豺 螳れ  蟲覃 i  1覯讌 覓狩  螳豺 螳れ 螳 伎.
- 磯殊 D[K]覦一伎 伎磯 朱 讌  .
- 企蟆 覃 覃覈襴襯 1/N 襷   !
- 企ゼ sliding window手 .
Code Explanation
POSTECH Computer Algorithm Team
Code
https://www.acmicpc.net/problem/12865
覯 覦磯
POSTECH Computer Algorithm Team
- 螳 覓語 豕  豕螳 覓視 蟆 , K覯讌碁  螳 覓視 蟆曙郁 .
- 譴覲給 覿覿 覓語れ 覃覈伎伎朱 豌襴 蟆 ,  讌 襦 豌襴.
- https://algospot.com/judge/problem/read/MORSE
- https://algospot.com/judge/problem/read/KLIS
K覯讌 
Kth solution
POSTECH Computer Algorithm Team
1. Brute force
- 豐 n螳 レ, m螳  .
- 企る 襷   覈 覿碁 豐 n+mCn 企.
- 覈 覿碁ゼ 覈 襷り, . 蠏 譴 k覯讌 覈る碁ゼ 豢ロ覃 .
- 螳覲旧° O(n+mCn log(n+mCn) )
- 轟壱 一.
MORSE
Kth solution
POSTECH Computer Algorithm Team
Kth solution
2. 朱願鍵
-  覈 螳 レ螻  , a螳 レ螻 b螳  り .
-  ル 伎 襷   覈 覿碁 れ螻 螳.
1. 朱  覈 覿 a+b-1Ca螳.
2. レ朱  覈 覿 a+b-1Cb螳.
- 襷 k < a+b-1Cb企, k覯讌 覈 覿碁 レ朱  覈 覿 譴 螻, 覃 朱 
覈 覿 る 蟆   給.
- 企蟆 讌 レ螻  覈   る 覈 覿瑚 旧 蟆   給.
POSTECH Computer Algorithm Team
Kth solution
 れ螻 螳.
D(a, b, k) : レ a螳,  b螳襦 襷   覈 覿碁 譴 k覯讌.
= - + D(a  1, b, k) (n > 0 and k <= a+b-1Cb)
= o + D(a, b  1, k  a+b-1Cb) (else)
Code Explanation
POSTECH Computer Algorithm Team
Code
https://algospot.com/judge/problem/read/MORSE
MORSE
POSTECH Computer Algorithm Team
- MORSE 螳 蠏狩覃 .
Q) MORSE 蟆曙,  レ語 語襯 蠍一朱 朱伎. KLIS 覓伎 蠍一朱 朱手?
KLIS
Kth solution
POSTECH Computer Algorithm Team
Kth solution
A) i覯讌 襯 朱  LIS 襦 朱企 .
- Count[i] : i覯讌 襯 朱  LIS 
- Lis[i] : i覯讌 襯 朱  LIS 蠍語
- Lis[i] = max(Lis[j] where i<j and S[i]<S[j]) + 1
- Count[i] = sum(Count(j) where i<j and S[i]<S[j] and Lis[i]=Lis[j]+1)
POSTECH Computer Algorithm Team
Kth solution
- 蟲企 Lis, Count襯 伎覃 れ螻 螳 k覯讌 LIS襯 蟲  .
Kth(i,skip) : i覯讌 襯 朱  LIS 譴 skip 覯讌 LIS.
= S[i] + Kth(j, skip  Count(j))
蠍一 j
- i<j, S[i]<S[j], Lis[i]=Lis[j]+1 襯 襷譟燕螻,
- sum(Count(ij) 譴  譟郁唄 襷譟燕 index) > skip 譴 螳  j
POSTECH Computer Algorithm Team
- Bitmask襯  DP .
- https://algospot.com/judge/problem/read/RESTORE
Bit DP
Bit DP
POSTECH Computer Algorithm Team
- 蟆磯覿 襷覃, 誤  覓語(TSP) 螳 覓語.
- 誤  覓語(TSP) : https://www.acmicpc.net/problem/2098
Q) RESTORE覓語襯 誤  覓語襦 豺企慨.
RESTORE
Bit DP
POSTECH Computer Algorithm Team
Bit DP
A)
- 螳 word襯 朱 .
- i覯讌 word れ j覯讌 word螳 り . 企覃 i覯讌 word 覩語 j覯讌 word  朱螳 蟆轟
蟆企. 企ゼ overlap(i, j)手 .
- ex) word, rdii => overlap(word, rdii) = 2
- i覯讌 word j覯讌 word襯  螳 觜 overlap(i, j)襦 覃 .
- 企ゼ 覈 word  伎 讌覃 .( 蠏碁)
POSTECH Computer Algorithm Team
Bit DP
1.  
- 1 ~ k word襯 危   覈 蟆曙磯ゼ 覲碁.
- 螳 蟆曙磯 overlap sum 螻壱.
- ( 蠍語 )  (overlap )   蟆曙磯ゼ 豢ロ.
- overlap 蟲 O(k), word襯 危 O(k!)
- 螳覲旧° O(k x k!)
- 轟壱 一!
Q) 蠍一 蟆轟 覿覿 覓語螳 螳?
POSTECH Computer Algorithm Team
Bit DP
2. DP
- 覈覈 れ 螻, 谿  here手 .
-  れ list襯 left手 .
- 螳企慨覃, (here, left)襯 襷譟燕 豕 蟆暑襯 蟲 蟆  讌 り骸 覓願.
- 讀,  覯 蟲覃 螻    => DP
- 磯殊 れ螻 螳  襷  .
D(here, left) :  here襦 螻,   left襯  蟆暑 譴, overlap    蟆暑
= max(overlap(here, next) + D(next, left  next))
Code Explanation
POSTECH Computer Algorithm Team
Code
https://algospot.com/judge/problem/read/RESTORE
RESTORE
POSTECH Computer Algorithm Team
- https://www.acmicpc.net/problem/10937
- https://algospot.com/judge/problem/read/ZIMBABWE
 企慨蠍
POSCAT
Thank you :-)

More Related Content

Similar to 01. dp hard (20)

DP Optimization
DP OptimizationDP Optimization
DP Optimization
麹 譟
貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx
貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx
貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx
ultrasuperrok
貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .
貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .
貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .
ultrasuperrok
03. segment tree
03. segment tree03. segment tree
03. segment tree
麹 譟
01. c and time complexity
01. c and time complexity01. c and time complexity
01. c and time complexity
麹 譟
DP 螻襴讀 覲伎.pdf
DP 螻襴讀  覲伎.pdfDP 螻襴讀  覲伎.pdf
DP 螻襴讀 覲伎.pdf
Ho Jeong Im
悌δ霏議
悌δ霏議悌δ霏議
悌δ霏議
Dongyi Kim
Dp 1
Dp 1Dp 1
Dp 1
DavidPark267
2019 ppc answers
2019 ppc answers2019 ppc answers
2019 ppc answers
麹 譟
Sqrt(n) algorithm
Sqrt(n) algorithmSqrt(n) algorithm
Sqrt(n) algorithm
麹 譟
Number theory
Number theoryNumber theory
Number theory
DavidPark267
Project#2襷 Hwp
Project#2襷 HwpProject#2襷 Hwp
Project#2襷 Hwp
Kimjeongmoo
[D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語
[D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語 [D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語
[D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語
NAVER D2
[D2≡=≡篠δ霏議]lovely algrorithm
[D2≡=≡篠δ霏議]lovely algrorithm[D2≡=≡篠δ霏議]lovely algrorithm
[D2≡=≡篠δ霏議]lovely algrorithm
NAVER D2
HI-ARC PS 101
HI-ARC PS 101HI-ARC PS 101
HI-ARC PS 101
Jae-yeol Lee
螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )
螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )
螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )
HYUNJEONG KIM
2018 Ajou Programming Contest solutions
2018 Ajou Programming Contest solutions2018 Ajou Programming Contest solutions
2018 Ajou Programming Contest solutions
襭蟲譟01
襭蟲譟01襭蟲譟01
襭蟲譟01
herojoon1378
DP Optimization
DP OptimizationDP Optimization
DP Optimization
麹 譟
貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx
貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx
貊ろ 蟆 蠍 C++ 00~ 01( 螻給覦覯).pptx
ultrasuperrok
貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .
貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .
貊 ろ 蟆 蠍 C++ 00~ 01レ 襴 螳襭 .
ultrasuperrok
03. segment tree
03. segment tree03. segment tree
03. segment tree
麹 譟
01. c and time complexity
01. c and time complexity01. c and time complexity
01. c and time complexity
麹 譟
DP 螻襴讀 覲伎.pdf
DP 螻襴讀  覲伎.pdfDP 螻襴讀  覲伎.pdf
DP 螻襴讀 覲伎.pdf
Ho Jeong Im
悌δ霏議
悌δ霏議悌δ霏議
悌δ霏議
Dongyi Kim
2019 ppc answers
2019 ppc answers2019 ppc answers
2019 ppc answers
麹 譟
Sqrt(n) algorithm
Sqrt(n) algorithmSqrt(n) algorithm
Sqrt(n) algorithm
麹 譟
Project#2襷 Hwp
Project#2襷 HwpProject#2襷 Hwp
Project#2襷 Hwp
Kimjeongmoo
[D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語
[D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語 [D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語
[D2 CAMPUS] 覿磯 Alcall 襦蠏碁覦 蟆曙 覓語
NAVER D2
[D2≡=≡篠δ霏議]lovely algrorithm
[D2≡=≡篠δ霏議]lovely algrorithm[D2≡=≡篠δ霏議]lovely algrorithm
[D2≡=≡篠δ霏議]lovely algrorithm
NAVER D2
螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )
螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )
螻襴讀 壱貂 碁碁 1-C (螻襴讀 り 覈碁 覦 )
HYUNJEONG KIM
2018 Ajou Programming Contest solutions
2018 Ajou Programming Contest solutions2018 Ajou Programming Contest solutions
2018 Ajou Programming Contest solutions

More from 麹 譟 (20)

RSS Live 際際滷r
RSS Live 際際滷rRSS Live 際際滷r
RSS Live 際際滷r
麹 譟
Parallel binary search
Parallel binary searchParallel binary search
Parallel binary search
麹 譟
Geometry Algorithms
Geometry AlgorithmsGeometry Algorithms
Geometry Algorithms
麹 譟
FFT
FFTFFT
FFT
麹 譟
Heavy light decomposition
Heavy light decompositionHeavy light decomposition
Heavy light decomposition
麹 譟
Advanced segment tree
Advanced segment treeAdvanced segment tree
Advanced segment tree
麹 譟
L-R network flow
L-R network flowL-R network flow
L-R network flow
麹 譟
MCMF
MCMFMCMF
MCMF
麹 譟
NIM game
NIM gameNIM game
NIM game
麹 譟
覿覲
覿覲覿覲
覿覲
麹 譟
String algorithm
String algorithmString algorithm
String algorithm
麹 譟
Tree algorithm
Tree algorithmTree algorithm
Tree algorithm
麹 譟
Number theory
Number theoryNumber theory
Number theory
麹 譟
06. sorting
06. sorting06. sorting
06. sorting
麹 譟
05. network flow 2
05. network flow 205. network flow 2
05. network flow 2
麹 譟
05 divide and conquer
05 divide and conquer05 divide and conquer
05 divide and conquer
麹 譟
04. network flow 1
04. network flow   104. network flow   1
04. network flow 1
麹 譟
04. binary search
04. binary search04. binary search
04. binary search
麹 譟
02. binary search tree
02. binary search tree02. binary search tree
02. binary search tree
麹 譟
03. dp easy
03. dp easy03. dp easy
03. dp easy
麹 譟
RSS Live 際際滷r
RSS Live 際際滷rRSS Live 際際滷r
RSS Live 際際滷r
麹 譟
Parallel binary search
Parallel binary searchParallel binary search
Parallel binary search
麹 譟
Geometry Algorithms
Geometry AlgorithmsGeometry Algorithms
Geometry Algorithms
麹 譟
Heavy light decomposition
Heavy light decompositionHeavy light decomposition
Heavy light decomposition
麹 譟
Advanced segment tree
Advanced segment treeAdvanced segment tree
Advanced segment tree
麹 譟
L-R network flow
L-R network flowL-R network flow
L-R network flow
麹 譟
NIM game
NIM gameNIM game
NIM game
麹 譟
覿覲
覿覲覿覲
覿覲
麹 譟
String algorithm
String algorithmString algorithm
String algorithm
麹 譟
Tree algorithm
Tree algorithmTree algorithm
Tree algorithm
麹 譟
Number theory
Number theoryNumber theory
Number theory
麹 譟
06. sorting
06. sorting06. sorting
06. sorting
麹 譟
05. network flow 2
05. network flow 205. network flow 2
05. network flow 2
麹 譟
05 divide and conquer
05 divide and conquer05 divide and conquer
05 divide and conquer
麹 譟
04. network flow 1
04. network flow   104. network flow   1
04. network flow 1
麹 譟
04. binary search
04. binary search04. binary search
04. binary search
麹 譟
02. binary search tree
02. binary search tree02. binary search tree
02. binary search tree
麹 譟
03. dp easy
03. dp easy03. dp easy
03. dp easy
麹 譟

01. dp hard

  • 1. By POSTECH Computer Algorithm Team DP Hard 譟一麹
  • 2. Contents POSTECH Computer Algorithm Team K覯讌 1 覦磯 覓語 0 Bit DP 2
  • 3. POSTECH Computer Algorithm Team - 企 碁碁 企れ DPれ 覦一. - 伎覲企 企れ, れ DPれ 給! - 蠏碁Μ螻 (螳)襷 蟲 蟆 , 旧 襷れ企企 豢ロ 覓語れ 襷朱, 譯殊蠍 覦. 螳
  • 4. POSTECH Computer Algorithm Team - 蠍磯蓋朱 DP覓語れ 危伎 蠏碁. - 蠏碁Μ螻 れ 豢ロ 覓語れ, 譴 襯 螻襯企 蟆曙郁 襷給.( 螳, 螳 ) - 危伎 蠍 覓語, 覓語襯 蠍 覓語螳 覦 蟆曙郁 給. - 蠏碁 企 覓語襯 伎伎 旧 讌 ロ 給. - 企蟆 ロ企 れ 磯手覃 れ 旧 襷れ企企 襷れ企 給. れ ? DP Hard
  • 5. POSTECH Computer Algorithm Team - 螳螳 螳讌螻 螳 覦磯 伎 覓願 豕螳 伎 螻, 殊 螳豺 覓願螳 讌れ 覦磯 l , 螳豺 豕螳 襦 讌 螻襯企 覦覯 谿城 覓語 - 譟壱 豕 覓語 - https://www.acmicpc.net/problem/12865 (螳豺 豢ロ 覓語) - https://algospot.com/judge/problem/read/PACKING (讌れ 豢ロ 覓語) 覦磯 覓語 Knapsack
  • 6. POSTECH Computer Algorithm Team Knapsack 1. Brute force - 螳 覓手唄 蟇磯 蟇磯, 豐 2 螳讌 螳 . - 2^N螳讌 蟆曙 譴, 譟郁唄(覦磯 覓願)襯 襷譟燕覃伎 螳豺螳 蟆 谿場朱 . - 螳 蟆曙磯 螳豺 蟲伎 覩襦, 螳覲旧° O(N x 2^N) - 轟壱蟆, 一も
  • 7. POSTECH Computer Algorithm Team Knapsack 2. 覯 覓願 K襯 伎企慨. - 1覿 i覯讌 覓狩 伎伎 覓願 w襯 襷れり . - 覓願螳 w螳 る, 1 ~ (i1)覯讌 覓狩 伎伎 w襯 郁, i覯讌 覓狩 讌 蟇磯 - 1 ~ (i-1)覯讌 覓狩 伎伎 w (i覯讌 覓狩 覓願)襯 襷り, i覯讌 覓狩 覃 .
  • 8. POSTECH Computer Algorithm Team Knapsack 讀, 1 ~ i覯讌 覓手唄 伎伎 覓願 w襯 襷れ , 螳豺 豕螳 れ螻 螳 蟲 . - D[i][w] = max(D[i 1][w], D[i 1][w (i覯讌 覓手唄 覓願)] + (i覯讌 覓手唄 螳豺)) - 1 <= i <= N, 0 <= w <= K 讌覃 . - 覯 , D[i][w] 豕螳 旧朱 豢ロ覃 . - 螳覲旧° O(NK)
  • 9. Code Explanation POSTECH Computer Algorithm Team Code https://www.acmicpc.net/problem/12865 覯 覦磯
  • 10. POSTECH Computer Algorithm Team Knapsack Q) 覓手唄 螳螳 譟郁襷 襷碁 覃覈襴螳 一. 覃覈襴襯 覦覯 蟾?
  • 11. POSTECH Computer Algorithm Team Knapsack A) D[K] 覦一企 ′ 豢覿 覓語襯 . - 螳企慨覃, D[i][w] D[i 1][1w] 螳襷 襦 - 讀, i覯讌 覓狩 螳豺 螳れ 蟲覃 i 1覯讌 覓狩 螳豺 螳れ 螳 伎. - 磯殊 D[K]覦一伎 伎磯 朱 讌 . - 企蟆 覃 覃覈襴襯 1/N 襷 ! - 企ゼ sliding window手 .
  • 12. Code Explanation POSTECH Computer Algorithm Team Code https://www.acmicpc.net/problem/12865 覯 覦磯
  • 13. POSTECH Computer Algorithm Team - 螳 覓語 豕 豕螳 覓視 蟆 , K覯讌碁 螳 覓視 蟆曙郁 . - 譴覲給 覿覿 覓語れ 覃覈伎伎朱 豌襴 蟆 , 讌 襦 豌襴. - https://algospot.com/judge/problem/read/MORSE - https://algospot.com/judge/problem/read/KLIS K覯讌 Kth solution
  • 14. POSTECH Computer Algorithm Team 1. Brute force - 豐 n螳 レ, m螳 . - 企る 襷 覈 覿碁 豐 n+mCn 企. - 覈 覿碁ゼ 覈 襷り, . 蠏 譴 k覯讌 覈る碁ゼ 豢ロ覃 . - 螳覲旧° O(n+mCn log(n+mCn) ) - 轟壱 一. MORSE Kth solution
  • 15. POSTECH Computer Algorithm Team Kth solution 2. 朱願鍵 - 覈 螳 レ螻 , a螳 レ螻 b螳 り . - ル 伎 襷 覈 覿碁 れ螻 螳. 1. 朱 覈 覿 a+b-1Ca螳. 2. レ朱 覈 覿 a+b-1Cb螳. - 襷 k < a+b-1Cb企, k覯讌 覈 覿碁 レ朱 覈 覿 譴 螻, 覃 朱 覈 覿 る 蟆 給. - 企蟆 讌 レ螻 覈 る 覈 覿瑚 旧 蟆 給.
  • 16. POSTECH Computer Algorithm Team Kth solution れ螻 螳. D(a, b, k) : レ a螳, b螳襦 襷 覈 覿碁 譴 k覯讌. = - + D(a 1, b, k) (n > 0 and k <= a+b-1Cb) = o + D(a, b 1, k a+b-1Cb) (else)
  • 17. Code Explanation POSTECH Computer Algorithm Team Code https://algospot.com/judge/problem/read/MORSE MORSE
  • 18. POSTECH Computer Algorithm Team - MORSE 螳 蠏狩覃 . Q) MORSE 蟆曙, レ語 語襯 蠍一朱 朱伎. KLIS 覓伎 蠍一朱 朱手? KLIS Kth solution
  • 19. POSTECH Computer Algorithm Team Kth solution A) i覯讌 襯 朱 LIS 襦 朱企 . - Count[i] : i覯讌 襯 朱 LIS - Lis[i] : i覯讌 襯 朱 LIS 蠍語 - Lis[i] = max(Lis[j] where i<j and S[i]<S[j]) + 1 - Count[i] = sum(Count(j) where i<j and S[i]<S[j] and Lis[i]=Lis[j]+1)
  • 20. POSTECH Computer Algorithm Team Kth solution - 蟲企 Lis, Count襯 伎覃 れ螻 螳 k覯讌 LIS襯 蟲 . Kth(i,skip) : i覯讌 襯 朱 LIS 譴 skip 覯讌 LIS. = S[i] + Kth(j, skip Count(j)) 蠍一 j - i<j, S[i]<S[j], Lis[i]=Lis[j]+1 襯 襷譟燕螻, - sum(Count(ij) 譴 譟郁唄 襷譟燕 index) > skip 譴 螳 j
  • 21. POSTECH Computer Algorithm Team - Bitmask襯 DP . - https://algospot.com/judge/problem/read/RESTORE Bit DP Bit DP
  • 22. POSTECH Computer Algorithm Team - 蟆磯覿 襷覃, 誤 覓語(TSP) 螳 覓語. - 誤 覓語(TSP) : https://www.acmicpc.net/problem/2098 Q) RESTORE覓語襯 誤 覓語襦 豺企慨. RESTORE Bit DP
  • 23. POSTECH Computer Algorithm Team Bit DP A) - 螳 word襯 朱 . - i覯讌 word れ j覯讌 word螳 り . 企覃 i覯讌 word 覩語 j覯讌 word 朱螳 蟆轟 蟆企. 企ゼ overlap(i, j)手 . - ex) word, rdii => overlap(word, rdii) = 2 - i覯讌 word j覯讌 word襯 螳 觜 overlap(i, j)襦 覃 . - 企ゼ 覈 word 伎 讌覃 .( 蠏碁)
  • 24. POSTECH Computer Algorithm Team Bit DP 1. - 1 ~ k word襯 危 覈 蟆曙磯ゼ 覲碁. - 螳 蟆曙磯 overlap sum 螻壱. - ( 蠍語 ) (overlap ) 蟆曙磯ゼ 豢ロ. - overlap 蟲 O(k), word襯 危 O(k!) - 螳覲旧° O(k x k!) - 轟壱 一! Q) 蠍一 蟆轟 覿覿 覓語螳 螳?
  • 25. POSTECH Computer Algorithm Team Bit DP 2. DP - 覈覈 れ 螻, 谿 here手 . - れ list襯 left手 . - 螳企慨覃, (here, left)襯 襷譟燕 豕 蟆暑襯 蟲 蟆 讌 り骸 覓願. - 讀, 覯 蟲覃 螻 => DP - 磯殊 れ螻 螳 襷 . D(here, left) : here襦 螻, left襯 蟆暑 譴, overlap 蟆暑 = max(overlap(here, next) + D(next, left next))
  • 26. Code Explanation POSTECH Computer Algorithm Team Code https://algospot.com/judge/problem/read/RESTORE RESTORE
  • 27. POSTECH Computer Algorithm Team - https://www.acmicpc.net/problem/10937 - https://algospot.com/judge/problem/read/ZIMBABWE 企慨蠍