POJ 1160 (interval DP + quadrilateral optimization)

Source: Internet
Author: User

POJ 1160 (interval DP + quadrilateral optimization)

This transfer equation is hard to think about, especially when the solution of a piece of value is intermediate. Dp [I] [j] uses I post offices to cover the minimum values of the first j villages.

There is also the parallelogram optimization of the interval dp. The transfer equation of this question is not "interval DP", so the enumeration state should be reversed (very time-consuming ), in addition, if a post office is used to overwrite the data, the data is dropped from 0, which means the data is not broken.

Compared to the standard interval DP, such as gravel merging and matrix chain multiplication, which is obtained before the required status.


# Include
 
  
# Include
  
   
# Include
   
    
Using namespace std; const int NN = 310; const int INF = 0x7fffffff; int n, m; int s [NN], dp [NN] [NN], w [NN] [NN], p [NN] [NN]; void get_w () // find ~ The minimum distance between building a post office in Village j and {for (int I = 1; I
    
     
// Parallelogram Optimization for straight-line stone extraction: # include
      
       
# Include
       
        
# Include
        
         
Using namespace std; const int INF = 1 <30; const int N = 1005; int dp [N] [N]; int p [N] [N]; int sum [N]; int n; int getMinval () {for (int I = 1; I <= n; I ++) {dp [I] [I] = 0; p [I] [I] = I; // The multiplication between yourself and yourself is naturally separated by yourself. } For (int len = 1; len
         
          

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.