The 13th session of Fuzhou University Program Design Competition _ re-summary

Source: Internet
Author: User
Tags ming

problem C Parallelogram numberaccept:82 submit:425
Time limit:2000 mSec Memory limit:32768 KBproblem Description

Given n points within a plane, any three points are not on the same line, how many parallelogram can be formed with these points? A point can belong to more than one parallelogram at a time.

Input

Multiple sets of data (<=10), processed to EOF.

The first row of each group of data is an integer n (4<=n<=500). The next n rows are two integers per line xi,yi (0<=XI,YI<=1E9), representing the coordinates of each point.

Output

Each set of data outputs an integer that indicates how many parallelogram can be formed with these points.

Sample Input0Sample Output1


Ideas :

Since three points are not on the same line , We only need to deal with the difference in X, y between any two points ,

For x, Y, as the first keyword, the second keyword, and then the same x, y How many pairs are there in total?




problem D Furnace stone legendaccept:54 submit:268
Time limit:1000 mSec Memory limit:32768 KBproblem Description

GG Seniors Although does not play the stone legend, but because the problem face need he learned to play the stone legend. But the traditional legend of the Furnace Stone is a little complicated for the newly-started GG seniors, so he decided to develop a simplified version of the Furnace Stone legend.

In the simplified version of the Furnace Stone legend:

Each companion has only health and damage, and under your turn, each of your followers can only choose one enemy follower to attack under this turn. When two followers A, a, a, a's health will be reduced by the attack of B, B's health will be subtracted from the attack of a, (two damage is not sequential, simultaneous settlement). If A or B's health value is not greater than 0, the attendant will die.

In one game, GG seniors and opponents have n followers on the scene, and they are GG seniors ' rounds. Since GG Seniors is a stubborn boy, he must kill all his followers in this round and make sure his followers are all alive. He wanted to know if he could do it.

Input

The first behavior T, which indicates that there is a T group of data. T<=100.

First behavior of each group of data n, indicating number of attendants (1 <= n <= 100)

Next line 2 * n digits A1, B1, A2, B2, ..., An, bn (1 <= ai, bi <= 100)

To represent GG Seniors ' n Entourage, Ai is the follower of life, Bi is the companion attack

Next line 2 * n digits C1, d1, C2, D2, ..., CN, DN (1 <= ci, di <= 100)

Represents the opponent's n Entourage, CI indicates the companion life, Di represents the attack.

Output

Each set of data, depending on whether GG can accomplish his goal, outputs a line of "Yes" or "No".

Sample Input234 4 5 5 6 (1 2 2 3 334 4 5 5 6) 4 2 4 3 4Sample OutputYesNo


Ideas :

Method One :

For each follower of GG i if he can kill each other's followers , then between I and these points to build the edge , and then the binary graph matches to determine if the match number is N just fine.

Complexity of Time : n^2

Method Two :

For GG 's entourage by the attack from small to large order , the other's entourage according to the amount of blood from small to large order , Then each follower attacks the entourage that he can kill with the greatest amount of damage and not greater than his blood ( which can be manipulated in the line segment Tree ).

Complexity of Time : Nlogn


problem E ~aptx4869accept:10 submit:48
Time limit:1000 mSec Memory limit:32768 KBproblem Description

To help Conan back to 1.74-meter, Dr. Agasa studied the antidote for APTX4869 day and night. He came to the following result:

1. The antidote is composed of n raw materials;

2. For two different raw materials, a, B, they have an impact value F (A, b);

3. The raw material needs to be divided into two parts x, Y and at least one raw material in each part;

4. The effect of the antidote is determined by the minimum impact value between the raw materials belonging to X, Y, respectively,

Effect =min{f (A, b) |a∈x,b∈y)}

The doctor needs your help to find out: In all scenarios, what can be the maximum effect value?

Input

Multiple sets of data (<=10), processed to EOF.

The first behavior of each set of data input is a positive integer n.

Next is an integer matrix of n rows n columns, separated by a space on the same line. The matrix I row J column represents the Influence value F (i,j) of the type I and J materials. The given matrix is symmetric, i.e. F (i,j) =f (j,i). When I=j, F (i,i) has no meaning, the value of the matrix is-1.

2<=n<=800. When I!=j, 0<=f (i,j) <=1000000; when I=j, F (i,j) =-1.

Output

Each set of data outputs a row that represents the maximum possible effect value.

Sample Input3-1 300100-1 200300 200-1Sample Output $


Ideas:

Another test instructions of the problem is to divide a ring into two rings, and the maximum value of the minimum value of the edges between the two rings.


Idea One:

Two-point answer,

Two-part process ideas:

Use and check set the edge length is less than the point of the answer to unite, judge this time is not only a ring


Idea two:

Sort by edges from small to large, processing the length of the side that joins the last edge so that all points are connected to one ring.


Problem F Ranch thing languageAccept:7 submit:119
Time limit:1000 mSec Memory limit:32768 KBproblem Description

The little tea students are playing with the pasture thing language. The game's map can be seen as a square with a side length of N.

The small tea students suddenly whim to cut the tree, however, the axe in the lower right of the small tea.

Xiao Ming is an efficient person, so he will take the shortest distance to the lower right corner, and then return to the upper left corner. And on the road will pick up/step on some items, such as flowers, money and stool and so on.

Items can only be taken at most once. In a lattice, if there are items on the lattice, you must take away. There may also be items at the start and end points.

Each item we will define a value for it, of course, after the return of the goods we get the value and the greater the better. But Xiao Ming students are seriously playing the game, please calculate the maximum value and.

Input

Multiple sets of data (<=10), processed to EOF.

The first line enters a positive integer N (n≤100), which represents the size of the square.

Next a total of n rows, n integers per line ai,j (| AI,J|≤10^9), indicating the value of the item at the corresponding location. A value of 0 means no items.

Output

Each set of data outputs an integer representing the maximum value and.

Sample Input211 1416Sample Output -

Ideas :

It is not difficult to see , can be converted from ( n,n) to Walk two times the square and the maximum number of possible

The analysis shows that the sum of the horizontal axis of each square is the time elapsed ,

DP[T][I][J] said that the time T, two people's horizontal axis is i,j; then their ordinate is t-i+1,t-j+1 ;

At the same time , If two people go to a point , They must have the same

So the transfer equation is dp[t][i][j]=max1 (dp[t-1][i][j],dp[t-1][i-1][j],dp[t-1][i][j-1],dp[t-1][i-1][j-1]) + (i==j?a[i][t+1-i ]:(A[i][t+1-i]+a[j][t+1-j] ));


problem G's excursionAccept:7 submit:44
Time limit:1000 mSec Memory limit:32768 KBproblem Description

The King of Darkness has a chessboard-like territory, the territory of the 2*10^9 line, there are 2*10^9 columns. Suppose the line of this territory is numbered 1 to 2*10^9 from top to bottom, and its columns are numbered 1 to 2*10^9 from left to right. We can count the squares in column J of line I as coordinates (I,J).

But the big chessboard is allowed to pass only to the N line-shaped areas that are given. Each linear area is described by three parameters, Ri,ai,bi (ai<= bi). The RI represents the row number for a given line region, the AI represents the starting column number for the line area, and BI represents the end number.

Now the king wants to reach the final coordinate box (X1,Y1) from a given grid of squares (x0,y0) through the minimum number of moves, and only through the permissible line-like areas given above.

The king moves one step only between adjacent squares. In addition, if two squares share at least one point we think they are next to each other.

Input

There are multiple sets of data (<=30) that are processed to the end of the file (EOF).

The first row of each group of data contains four integers, x0, y0, x1, y1 (1 <= x0, y0, x1, y1 <= 2*10^9) representing the king's initial and end coordinates, respectively.

The second line has an integer n (1 <= N <= 10^5), which represents a linear area of n passable.

Next, there will be n rows, the line I contains three integers, Ri,ai, bi (1 <= ri, ai bi <= 2*10^9), meaning to see the surface.

The data allows the linear area to cross or nest.

The data guarantees that the king's starting and ending squares are passable, and the two regions are not the same. Also ensure that the sum of the lengths of all linear areas does not exceed 10^5.

1 <= x0, y0, x1, y1, RI, Ai, bi<= 2*10^9,1 <= N <= 10^5

Output

If there is no road that allows the king to reach the finish area from the starting area, output-1.

Otherwise, the minimum number of steps for the king to reach the finish area from the start area is output.

Sample Input5 7 6 each35 3 86 75 2 51 1 221 1 32 6Sample Output4-1

Idea: Because only 10^5 points, so we can first deal with what points are can go, and then from the end to the starting point, a simple bfs can be.



Median of problem IAccept:4 Submit:8
Time limit:1500 mSec Memory limit:131072 KBproblem Description

There is a tree of n nodes, the node number 1-n. Each edge of the tree has a weight, now give a Q query, each query gives two points u,v, indicating an endpoint is the path of u,v, now to ask the edge of the path of the weight of the median is how much, if the path length is even, then there are two median, take the smaller one to output.

Input

Multiple sets of data (<=5), processed to EOF.

The first line input two number n, Q, next n-1 line three number u,v,w, indicating that there is an edge between U and V, and its weight is w, followed by Q line, each line two number u, V, indicating the path of the inquiry.

1<=n,q<=5*10^4

1<=u, V<=n,u!=v

0<=w<=10^5

Output

Each set of data output Q lines, one number per line, represents the answer.

Sample Input7 72 1 13 1 21 4 04 5 15 6 35 7 41 34 12 42 53 53 63 7Sample Output2001111

Ideas:

We can turn the edge into a point value, and then use the K stool on the tree to simply solve


The 13th session of Fuzhou University Program Design Competition _ re-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.