#P5441. 【XR-2】伤痕

    ID: 4377 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学Special JudgeO2优化组合数学构造

【XR-2】伤痕

Description

Country X has suffered an unprecedented earthquake. People are covered in scars, and the whole country is shattered.

To help people heal, and also to allow Country X to survive, the King of Country X decides to rebuild the country.

The King decides to first build nn cities. Since the King likes odd numbers, nn is odd.

After the cities are built, a road must be built between every pair of cities, i.e., a total of n(n1)2\frac{n(n-1)}{2} roads.

However, the cost of building bidirectional roads is too high. After building nn cities, the remaining budget is enough to build at most nn bidirectional roads, and all other roads can only be built as one-way roads. Fortunately, the direction does not affect the cost of building a one-way road, so the directions of all one-way roads can be chosen arbitrarily.

In addition, after the rebuilding is completed, the King will designate 44 cities as the core cities of Country X. To promote the development of Country X, for any two of these 44 core cities, they must be able to reach each other without passing through non-core cities.

The King hopes that you can provide him with a road construction plan such that, after the rebuilding is completed, the number of ways to choose 44 core cities is maximized.

Input Format

One line containing a positive integer n(1n99)n(1 \le n \le 99), guaranteed that nn is odd, meaning there are nn cities.

Output Format

The first line contains an integer, representing the maximum number of ways to choose 44 core cities.

The next nn lines each contain nn positive integers describing an adjacency matrix, representing your road construction plan.

Specifically, the jj-th number in the ii-th line is 11 if city ii can reach city jj via a road, and 00 if city ii cannot reach city jj via a road. We explain in detail in 33 cases:

  1. If the road between ii and jj is a one-way road from ii to jj, then the number in row ii, column jj of the adjacency matrix is 11, and the number in row jj, column ii is 00.
  2. If the road between ii and jj is a bidirectional road, then both the number in row ii, column jj and the number in row jj, column ii are 11. You must ensure that at most nn bidirectional roads are built.
  3. If i=ji = j, then the number in row ii, column jj (the number in row jj, column ii) is 00.
3

0
0 1 1
0 0 1
0 1 0

5

5
0 1 0 1 1
0 0 1 1 0
1 0 0 0 1
1 0 1 0 1
1 1 0 0 0

Hint

[Sample 11 Explanation]

Since there are only 33 points in total, the number of ways to choose 44 core cities must be 00. So you only need to ensure that the construction plan satisfies the requirements.

[Sample 22 Explanation]

Obviously, among 55 points, choosing any 44 points satisfies the core-city condition, so the maximum number of ways is 55.

[Constraints]

This problem has 5050 test points, each worth 22 points. For the ii-th test point, n=2i1n = 2i - 1.

For each test point, there are five possible outcomes:

  1. Output format error, including: not outputting the maximum number of ways, not outputting the adjacency matrix, outputting extra information, etc. You will not get any points for this test point, and we cannot determine the return result of the Special Judge.
  2. The maximum number of ways is not computed correctly, even if the constructed road plan is correct. You will get 0%0\% of the score for this test point (i.e., 00 points). The Special Judge will return WA and output “The answer is wrong.”
  3. The maximum number of ways is computed correctly, but the constructed road plan does not satisfy the requirements, including: numbers in the adjacency matrix that are not 00 or 11, self-loops, a pair of cities with no road between them, more than nn bidirectional roads, etc. You will get 50%50\% of the score for this test point (i.e., 11 point). The Special Judge will return WA and output “The answer is correct, but your plan breaks the rules.”
  4. The maximum number of ways is computed correctly, and the constructed road plan satisfies the requirements, but the number of ways to choose 44 core cities is not maximized. You will get 50%50\% of the score for this test point (i.e., 11 point). The Special Judge will return WA and output “The answer is correct, but your plan is wrong.”
  5. The maximum number of ways is computed correctly, and the road construction plan is also constructed correctly. You will get 100%100\% of the score for this test point (i.e., 22 points). The Special Judge will return AC and output “The answer is correct.”

Translated by ChatGPT 5