10.11 Exam Summary

Source: Internet
Author: User

10.11 Exam Summary

All DP actually found that violence can also have partial points ....

Triangle Ranch

Dp...... It didn't feel like that at the time.

What you need to deal with is the possibility of enumerating the length of the triangle. Because the perimeter can be determined at the input, you can force the third edge to be calculated by enumerating the two edges ....

So save space + time ....

f[0][0] = 1;    for (int i=1; i<=n; ++i)        for(int j=half; j>=0; j--)            for(int k=j; k>=0; k--)                if(j >= d[i] && f[j-d[i]][k] || k >= d[i] && f[j][k-d[i]])                    f[j][k] = 1;

Find the presence of a number of edges

And then it's deciding whether to make a triangle or not.

for (int i=half; i>=1; --i)    for (int j=i; j>=1; --j)        if (f[i][j])            f (check(i, j, tot - i - j))                ans = max(ans, area(i, j, tot - i - j));

And then it's done ....

Dominoes

DP ... again. I do not have feelings directly calculated the difference between the top and bottom, and then directly calculate one side. But this has a negative answer to appear, so to deal with a positive number is good ...

And then we'll find the answer.

for(int i=1; i<=n; i++)    for(int j=-5000; j<=5000; j++)        f[i][j+M] = min(f[i-1][j-c[i]+M], f[i-1][j+c[i]+M]+1);for(int i=0; i<=5000; i++){    ans = min(f[n][i+M], f[n][-i+M]);    if(ans <= 1000)//因为n小于1000,所以最多翻转肯定是1000以内    {        printf("%d\n", ans);        break;    }}
Mowing the lawn

Deduce the formulas you have listed.

First F[i] is as an end point, F[j] is a breakpoint.

So

F[i]=max (F[i],f[j-1]+a[j+1]+a[j+2]......a[i]) (i-k<=j<=i)

Then we find that we can prefix and optimize on a wave.

F[i]=max (F[i],f[j-1]+sum[i]-sum[j]) (i-k<=j<=i)

Then found in I, Sum[i] is actually a definite value, so can be proposed to

F[i]=max (F[i],f[j-1]-sum[j]) +sum[i] (i-k<=j<=i)

The discovery is only associated with J and always finds the maximum value.

And then go to know what is a monotone queue, to ensure that the number in the queue is monotonous, the output front of the maximum value can be

IL ll top(int i){    d[i] = f[i-1] - sum[i];    while (head <= tail && d[q[tail]] < d[i]) tail--;    q[++tail] = i;    while (head <= tail && q[head] < i - k) head++;    return d[q[head]];}

Monotone queue, then use this to find the maximum value

for(int i=1; i<=n; i++) f[i] = top(i) + sum[i];
A simple task.

This mission is not simple.

Pressure DP ... Dismissal issues

10.11 Exam Summary

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.