11,293 Country Games

Source: Internet
Author: User

11,293 Country Games

2010 NOIP National League popularity Group

time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingView Run ResultsTitle Description Description

Xiao Han is fond of computer games, these days he is playing a game called "Three Kingdoms". In the game, the small culvert and the computer each party, the formation of their respective armies to battle. There is a total of N-Generals in the game (n is even and not less than 4), and any two generals have a "tacit value", indicating how powerful the combination would be if the two generals fought as a pair. Before the game began, all the generals were free (called the Free Generals, once a free warlord was chosen as a member of a certain army, then he was no longer a free warlord), in other words, the so-called free generals do not belong to either party. The game begins, the small culvert and the computer to choose from a free warlord to form their own army, the rules are as follows: Xiao Han first elected a free military commander to join his own army, and then the computer from the free generals elected a computer to join the army. Followed by the "small culvert → computer → small Culvert → ..." in the order of the selection of the generals, until all the generals were evenly divided between the two sides. Then, the program automatically from both sides of the army to pick out a pair of the highest tacit value of the generals on behalf of their own army to carry out two to two competitions, with a higher tacit value of the combination of a pair of generals win, said the two armies, with the victory of the winning military combination of the party won. It is known that the principle of choosing a warlord is to try to undermine the strongest combination that the opponent will form next, and it takes the following specific strategies: any time, when it is time to pick up the computer, it will attempt to match each of the generals in the opponent's army with one by one of each of the current free generals, to find out the combination of the strongest pairs And elect the free generals in the group into their own armies. The following is an example of a computer's selection strategy, for example, a total of 6 generals in the game, their mutual tacit values are shown in the following table
Xiao Han want to know, if the computer in a game always adhere to the above strategy, then it is possible to win? If so, in all possible victories, what is the maximum amount of tacit understanding of the combination of the generals used in the tournament? Assume that during the entire game, both sides can see the generals of the free generals and the generals of the opposing armies at any time. In order to simplify the problem, it is ensured that the tacit value of the different generals ' combinations is not the same.

There is n≤10 for 40% of the data.
There is n≤18 for 70% of the data.
n≤500 for 100% of data

Enter a description Input Description

Enter a total of n rows. The first behavior is an even n, which represents the number of generals. Line 2nd to Nth Line, i+1 (n−i) a non-negative integer, each two numbers separated by a space, indicating the tacit value between the commander I and the I+1,i+2,......,n (0≤ tacit value ≤1,000,000,000).

Output description Output Description

Outputs a total of 1 or 2 rows. If for a given game input, there can be a small culvert to win the election sequence, then output 1, and another line output all the winning case, the small culvert the ultimate selection of the maximum tacit value of the combination of generals. If there is no choice to let the small culvert win the order, then output 0.

Sample input Sample Input

6
5 28 16) 29 27
23 3 20 1
8 32 26
33 11
12

Sample output Sample Output

1
32

Data range and Tips Data Size & Hint

First, the small Han took the No. 5th Military commander; the computer found that the number 5th and the remaining generals in the 4th tacit value of the highest, so take away the number 4th; Small culvert then took 3rd; computer found that 3 and 5th of the generals and the remaining generals paired with all combinations, 5th and 1th are the highest tacit value, so take the 1th number; The computer finally took number 6th. In the small Han hand of the 2,3,5, 3rd and 5th with the best, tacit value of 32, and the computer can be launched by the best combination of 1th and 6th, tacit value of 27. The result is small culvert wins, and this combination is the best combination that the small culvert can take out of all methods.

Category labels Tags Click here to expandNOIP National League popular Group mainland region 2010 years AC Code:
//1, small culvert can not choose the maximum tacit value. //2, small culvert can not lose. //Therefore, it is only possible to select the maximum value of the tacit value that each warlord can combine. #include <cstdio>using namespacestd;Const intn=1e3+Ten;intN,max1,max2,a[n][n];intans=-1;intMain () {scanf ("%d",&N);  for(intI=1; i<=n;i++){         for(intj=i+1; j<=n;j++) {scanf ("%d",&A[i][j]); A[j][i]=A[i][j]; }    }     for(intI=1; i<=n;i++) {Max1=max2=0;  for(intj=1; j<=n;j++){            if(a[i][j]>max1) {Max2=Max1; Max1=A[i][j]; }            Else if(a[i][j]>max2) {Max2=A[i][j]; }        }        if(ANS&LT;MAX2) ans=Max2; } printf ("1\n%d", ans); return 0;}

11,293 Country Games

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.