NOIP2014 flying Birds to the puzzle

Source: Internet
Author: User
problem face "Problem description"

Flappy Bird is a rage casual mobile game. Players need to constantly control the number of clicks on the phone screen to adjust the bird's flight altitude, so that the bird smoothly through the screen to the right of the pipe gap. If the bird accidentally hit the water pipe or dropped on the ground, it will be declared a failure.
To simplify the problem, we have simplified and adapted the rules of the game:
1. The game interface is a two-dimensional plane with a length of N and a height of M, which has
K Pipes (ignoring the width of the pipe).
2. Birds always move within the game interface. Birds from the game interface to the left of the most arbitrary integer height position, to the game interface to the far right, the game completed.
3. The distance of the bird to the right of each unit time along the horizontal axis is 1, the distance of vertical movement is controlled by the player. If you click on the screen, the bird will rise to a certain height x, each unit time can be clicked several times, the effect is superimposed; If you do not click on the screen, the bird will drop a certain height y. When the birds are in different positions in the direction of the horizontal axis, the ascending height x and the descending height y may not be the same.
4. The bird height is equal to 0 or when the bird touches the pipe, the game fails. When the bird height is m, can not rise again.
5. Now, please decide whether you can finish the game. If you can, output at least click on the number of screens, otherwise, the maximum number of birds can pass through the pipe gap. "Input"

The input file name is bird.in.
Line 1th has 3 integer n,m,k, respectively, the length of the game interface, height and the number of water pipes, each of the two integers separated by a space;
The next n rows, 2 integers x and y separated by a space in each row, indicate the height x of the bird in the next position, and the height of the bird in the next position when the player clicks on the screen in the 0~n-1 position.
Next line K, each row is 3 integers p,l,h, separated by a space between every two integers. Each line represents a pipe in which p represents the horizontal axis of the pipe, and L indicates the height of the bottom edge of the pipe gap as l,h indicates the altitude of the top edges of the pipe gap (the input data guarantee p varies, but is not guaranteed to be given in order of magnitude). "Output"

The output file name is Bird.out.
A total of two lines.
The first line, containing an integer, if the game can be successfully completed, output 1, otherwise output 0.
The second line, contains an integer, if the first behavior 1, then the output successfully completed the game need to click the minimum number of screens, otherwise, the output of birds can be up to how many pipe gaps. "Input and Output sample 1"

Bird.in
10 10 6
3 9
9 9
1 2
1 3
1 2
1 1
2 1
2 1
1 6
2 2
1 2 7
5 1 5
6 3 5
7 5 8
8 7 9
9 1 3
Bird.out
1
6 "Input and Output sample 2"

Bird.in
10 10 4
1 2
3 1
2 2
1 8
1 8
3 2
2 1
2 1
2 2
1 2
1 0 2
6 7 9
9 1 4
3 8 10
Bird.out
0
3 "Data range"

For 30% of the data: 5≤n≤10,5≤m≤10,k=0 5≤n≤10,5≤m≤10,k=0, to ensure the existence of a set of optimal solution to the same unit time to click the screen 3 times;
For 50% of the data: 5≤n≤20,5≤m≤10 5≤n≤20,5≤m≤10, to ensure the existence of a set of optimal solution to the same unit time to click the screen 3 times;
For 70% of the data: 5≤n≤1000,5≤m≤100 5≤n≤1000,5≤m≤100;
For 100% of the data: 5≤n≤10000,5≤m≤1000,0≤k<n,0<x<m,0<y<m,0<p<n,0≤l Analysis of 5≤m≤1000,0≤k

This problem is easy to come up with an O (NM 2) O (nm^2) dynamic regulation
That is, F[i][j] f[i][j] represents the minimum number of clicks required to fly to the I-column J-height i-column position.
f[i][j]=min{f[i−1][j−k∗x]+k},1≤k≤j/x (O (M)) (not considering the fall of the Feeling

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.