Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

0

Share

Download to read offline

Meet inthemiddle

Download to read offline

meet in the middle

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Meet inthemiddle

  1. 1. HCPC 2017/03/14 HCPC - - 3
  2. 2. HCPC 2017/03/14 • …… • • • "Meet in the middle" • O(poly(N) 2N/2 ) 
 N≤40
  3. 3. HCPC 2017/03/14 • …… • • • "Meet in the middle" • O(poly(N) 2N/2 ) 
 N≤40 ???
  4. 4. HCPC 2017/03/14 : 4 Values whose Sum is 0
 (POJ 2785, p.147) • : 4 A, B, C, D ( n) • : 1 
 0 • : 1 ≤ n ≤ 4,000, | | ≤ 228 A B C D 1 + 3 + (-3) + (-1) = 0 :
  5. 5. HCPC 2017/03/14 : 4 Values whose Sum is 0
 (POJ 2785, p.147) • : 4 A, B, C, D ( n) • : 1 
 0 • : 1 ≤ n ≤ 4,000, | | ≤ 228 A B C D 0 + (-2) + (-3) + (-1) = -6 :
  6. 6. HCPC 2017/03/14 : 4 Values whose Sum is 0
 (POJ 2785, p.147) • : 4 A, B, C, D ( n) • : 1 
 0 • : 1 ≤ n ≤ 4,000, | | ≤ 228 A B C D 1 + 3 + (-3) + (-1) = 0 1 + 3 + (-3) + (-1) = 0 0 + (-2) + 3 + (-1) = 0 Ans. 3 :
  7. 7. HCPC 2017/03/14 TLE : • 4 • n4 = 2.56 × 1014 
 →
  8. 8. HCPC 2017/03/14 : ( ) • A, B C, D • O(n2 ) • ABi + CDj = 0 (i, j) 
 →
  9. 9. HCPC 2017/03/14 : ( ) • i ABi = -CDj j • CD • ABi CDj 
 - ABi CDj • O(n2 log n2 )
  10. 10. HCPC 2017/03/14 : 
 ( p. 148) • : vi wi N S • : S 
 • : 1 ≤ N ≤ 40, 1 ≤ vi, wi, S ≤ 1015 : w1 = 2 w2 = 1 w3 = 3 w4 = 2 S = 5
  11. 11. HCPC 2017/03/14 : 
 ( p. 148) • : vi wi N S • : S 
 • : 1 ≤ N ≤ 40, 1 ≤ vi, wi, S ≤ 1015 : w1 = 2 w2 = 1 w3 = 3 w4 = 2 S = 5 Σw = 6
  12. 12. HCPC 2017/03/14 : 
 ( p. 148) • : vi wi N S • : S 
 • : 1 ≤ N ≤ 40, 1 ≤ vi, wi, S ≤ 1015 : w1 = 2 w2 = 1 w3 = 3 w4 = 2 S = 5 Σw = 4 Σv = 6
  13. 13. HCPC 2017/03/14 : 
 ( p. 148) • : vi wi N S • : S 
 • : 1 ≤ N ≤ 40, 1 ≤ vi, wi, S ≤ 1015 : w1 = 2 w2 = 1 w3 = 3 w4 = 2 S = 5 Σw = 5 Σv = 7
  14. 14. HCPC 2017/03/14 TLE : DP • • dp[i][j] := i j 
 • dp[N][S] • : O(NS) → S=1015
  15. 15. HCPC 2017/03/14 TLE : • ( ) • / • Σw ≤ S ans ← max(ans, Σv) • DP • : O(2N) → N=40 1012
  16. 16. HCPC 2017/03/14 : ( ) • 220 ≒ 106 • N/2 • : O(N/2 2N/2)
  17. 17. HCPC 2017/03/14 : ( ) • • wX < wY vX > vY Y • wX < wY vX < vY w v • : O(2N/2 log2N/2 ) = O(N/2 2N/2 )
  18. 18. HCPC 2017/03/14 : ( ) • W S-W • wX vX S-W → • : O(2N/2 log2N/2 ) = O(N/2 2N/2 )
  19. 19. HCPC 2017/03/14 : (AOJ 1161) • : N • : := 0~9 
 N 
 ( 0 ) • : N-1 = 1 • : 3 ≤ N ≤ 12, 1 ≤ | | ≤ 8 : 

  20. 20. HCPC 2017/03/14 : (AOJ 1161) • : N • : := 0~9 
 N 
 ( 0 ) • : N-1 = 1 • : 3 ≤ N ≤ 12, 1 ≤ | | ≤ 8 :
  21. 21. HCPC 2017/03/14 : (AOJ 1161) : • : N • : := 0~9 
 N 
 ( 0 ) • : N-1 = 1 • : 3 ≤ N ≤ 12, 1 ≤ | | ≤ 8, 1≤ ≤10
  22. 22. HCPC 2017/03/14 • "ABCD" A×103 + B×102 + C×101 + D×100 • kA×A + kB×B + ... kZ×Z = 0 
 ( ) • kA kZ A~Z
  23. 23. HCPC 2017/03/14 : • M • 10PM • : 10*10! ≒ 3.6×107
  24. 24. HCPC 2017/03/14 : ( ) • (M/2) • (= 10CM/2 ) • (= (M/2)! ) • •
  25. 25. HCPC 2017/03/14 : ( )
  26. 26. HCPC 2017/03/14 : ( ) • (10CM/2 × 10CM/2) • NG • X -X • • : O( (10CM/2) 2 (M/2)! log(M/2)! ) • M=10 1.5 × 10 7 • ( )
  27. 27. HCPC 2017/03/14 : ( )
  28. 28. HCPC 2017/03/14 • 
 2 • • • N≤40

meet in the middle

Views

Total views

775

On Slideshare

0

From embeds

0

Number of embeds

1

Actions

Downloads

6

Shares

0

Comments

0

Likes

0

×