Full Simulation (1) day1

Source: Internet
Author: User

Question 1:

Question:

Given the M relationship of N numbers (A, B), it means a is greater than B. Each number must be at least 100, and the minimum possible sum of these books is required.

 

Problem solving process:

1. when we see this question, we think of a previous usaco question. The question is nheaded Niu sorting, and then the M pair relationship (a, B) indicates that a is placed before B, then, you can determine the locations of the cattle. As long as the DFS for each point 2 times find for each ox, how many is bigger than it, how many is smaller than it, if the sum is N-1, then you can determine the position of the cow. this question is similar. For each vertex, You can process the maximum number of vertices smaller than it.

2. The specific method is to first make a topological sorting to determine whether there is a ring, eliminate the case of no solution, and then DP according to the topological order. D [I] = max {d [I. Child] + 1 }. The last step is to accumulate.

 

 

Question 2:

Question:

A grid map of N * m, laying pipelines for it (that is, a game with a connection pipe on a mobile phone ). Some grids have been paved, and some cannot be paved. Calculate the number of solutions to connect () and (n, m. There are only four types of water pipes:

 

Problem solving process:

1. Very bare DP. It can be found that no matter how the water pipe is connected, it can only go down or to the right, so it becomes a river .. Directly f [I] [J] [k] indicates going to (I, j) and putting the number of solutions for the No. K pipe in the grid, and then let's go through the recursion.

2. The status may also be squashed into two dimensions. The problem can be converted to the number of solutions from () to (n, m). Some grids have defined the direction, and some grids cannot go. Then you can only go to the right or down.

 

 

Question 3:

Question:

There are n tasks, each task has a arrival time AI, the latest completion time bi, the time required to complete ti. starting from time 0, if a job has arrived and can be completed on time, you must select a job. Obtain the minimum working time.

Ti> = 1200 <= ai, Bi <= 1000, n <=, bi-AI must be greater than or equal to Ti and less than 2Ti.

 

Problem solving process:

1. Directly think of DP by time. f [I] indicates the minimum working time when I starts work. The equation transfer is also very simple:

If I has no task to do at the moment, it is clear that f [I] = f [I + 1];

If a task is to be executed, F [I] = min (F [I + TJ] + TJ ).

2. after writing the test, I set all the five work Ti to 1 and found that the answer is 7. Then I found that the question "Bi-AI must be greater than or equal to Ti, and less than 2Ti "is not nonsense... Without this sentence, the above equation is incorrect, because the same task may have been done several times.

 

Today's question is just a bit watery, and it's all done in an hour... The font of the compiler does not know which one to choose, and the font is disgusting. A for statement occupies half of the screen width ..

Full Simulation (1) day1

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.