#P1199. [NOIP 2010 普及组] 三国游戏

[NOIP 2010 普及组] 三国游戏

Description

{{Xiaohan loves computer games, and these days he is playing a game called "Three Kingdoms."

In the game, Xiaohan and the computer control opposing sides, each assembling their own army to battle. There are N N generals in total (where N N is even and at least 4 4 ). Between any two generals there is a "synergy value," indicating how powerful a pair would be if they fight together. Before the game starts, all generals are free (called free generals; once a free general is chosen as a member of a side's army, he is no longer a free general). In other words, free generals do not belong to any side.

When the game begins, Xiaohan and the computer take turns selecting generals from the free generals to form their armies, following these rules: Xiaohan first selects one free general to join his army, then the computer selects one free general to join the computer's army. They continue selecting in the order "Xiaohan → computer → Xiaohan → …" until all generals are evenly split between the two sides. Then, the program automatically selects from each army the pair of generals with the highest synergy value to represent that army in a two-on-two duel. The side whose pair has the higher synergy value wins the duel; that side wins the battle.

It is known that the computer's principle for choosing is to disrupt the opponent's strongest possible pair on the opponent's next move as much as possible. Its specific strategy is as follows: whenever it is the computer's turn, it tries pairing each general already in the opponent's army with each current free general, finds the pair with the highest synergy value among all such pairings, and then picks the free general from that pair into its own army. For example, suppose there are 6 6 generals in total, and their pairwise synergy values are as shown below:

General ID 1 2 3 4 5 6
1 55 2828 1616 2929 2727
2 55 2323 33 2020 11
3 2828 2323 88 3232 2626
4 1616 33 88 3333 1111
5 2929 2020 3232 3333 1212
6 2727 11 2626 1111 1212

The selection process is as follows:

Xiaohan Free generals available to the computer on its turn Computer Computer's choice explanation
Round 1 55 1,2,3,4,61,2,3,4,6 4\color{magenta}4 The synergy value between Xiaohan's 55 and 44 is the highest, so the computer selects 44.
Round 2 5,35,3 1,2,61,2,6 4,14,\color{magenta}1 The maximum synergy value that can be formed by pairing Xiaohan's 55 and 33 with a free general is 2929, produced by pairing 55 with 11, so the computer selects 11.
Round 3 5,3,65,3,6 22 4,1,24,1,\color{magenta}2

Xiaohan wants to know: if the computer always sticks to the above strategy in a game, is it possible for him to force a win? If yes, among all possible winning outcomes, what is the maximum synergy value of the pair of generals he finally uses for the duel?

Assume that throughout the game, both sides can always see the free generals and the opponent's chosen generals. To simplify the problem, it is guaranteed that for different pairs of generals, their synergy values are all distinct.}}

Input Format

{{A total of N N lines.

The first line contains an even integer N N , the number of generals.

From the 2 2 -nd line to the N N -th line, line i+1 i+1 contains Ni N-i non-negative integers separated by single spaces, representing the synergy values between general i i and generals i+1,i+2,,N i+1,i+2,\dots,N (0默契值1090 \le \text{默契值} \le 10^9).}}

Output Format

{{One or two lines in total.

If there exists a selection sequence that allows Xiaohan to win for the given input, output 1 1, and on the next line output the maximum synergy value of Xiaohan's final chosen pair among all winning cases. If no such selection sequence exists, output 00.}}

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

1
32


8 
42 24 10 29 27 12 58 
31 8 16 26 80 6 
25 3 36 11 5 
33 20 17 13 
15 77 9 
4 50 
19 
1
77

Hint

{{Constraints

For 40% 40\% of the testdata, N10N≤10.

For 70% 70\% of the testdata, N18 N≤18.

For 100% 100\% of the testdata, 4N5004\le N≤500. It is guaranteed that for different pairs of generals, their synergy values are all distinct.

NOIP 2010 Junior Problem 4.}}

Translated by ChatGPT 5