#P11025. [COTS 2020] 辣椒 Sadnice

    ID: 12438 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2020Special JudgeO2优化COCI(克罗地亚)

[COTS 2020] 辣椒 Sadnice

Background

Translated from Izborne Pripreme 2020 (Croatian IOI/CEOI Team Selection) D1T3. 3s,0.5G\texttt{3s,0.5G}.

Problem Description

Peppers are planted in a garden. The garden can be described as an (N+1)×(M+1)(N+1)\times (M+1) grid graph, where the peppers are planted on the grid points. She also uses [(N+1)×(M+1)1][(N+1)\times (M+1)-1] ropes to connect adjacent grid points, so that any two pepper plants can reach each other through the ropes. In other words, the ropes form the edges of a spanning tree of this grid graph.

Define two pepper plants to be connected if and only if they are directly or indirectly connected by ropes.

At night, someone will come to sabotage. The saboteur will make one straight cut either horizontally or vertically, cutting all ropes that the cut passes through. After the cut, the pepper plants will be split into several connected components. The saboteur will try to maximize the number of connected components.

How should you arrange the ropes so that, after the cut, the number of connected components is as small as possible?

Input Format

One line with two positive integers N,MN, M.

Output Format

Output (2N+1)(2N+1) lines, each containing (3M+1)(3M+1) characters.

Among them, in line (2i1)(2i-1), the (3j2)(3j-2)-th character represents the point (i,j)(i,j) (the plant in row ii, column jj), denoted by o (ASCII 111).

For two points (i,j)(i,j) and (i,j+1)(i,j+1) in the same row, if there is an edge, fill the two spaces between them with -- (ASCII 45); otherwise, do not fill them.

For two points (i,j)(i,j) and (i+1,j)(i+1,j) in the same column, if there is an edge, fill the one space between them with | (ASCII 124); otherwise, do not fill it.

All unfilled areas should be padded with spaces. Do not output extra spaces or extra blank lines.

You may refer to the sample output.

2 2
o--o  o
|     |
o  o--o
|     |
o--o--o
2 2
o--o--o
|
o  o--o
|     |
o--o--o

Hint

Scoring

If your output is an optimal solution, you get full score for that test point.

Otherwise, the score multiplier is computed as follows:

$$K=0.75\times \max\left\{\left(\frac{A-1}{B-1}\right)^4,1-\left(1-\frac{1}{(B-A)^2}\right)^6\right\}$$

Where AA is the optimal answer, and BB is the answer of your construction.

You will get KK times the score of that test point. The subtask score is the minimum score among the test points in that subtask.

For example, Sample 1 gets full score. Sample 2 gets 75%75\% of the score.

Constraints

For 100%100\% of the data, it is guaranteed that 1NM10001\le N\le M\le 1\, 000.

Subtask ID N,MN, M\le Special Property Score
1 1 10001\,000 A 15 15
2 2 B
3 3 33 5 5
4 4 1010 10 10
5 5 100100 20 20
6 6 10001\, 000 35 35
  • Special Property A: N=MN=M.
  • Special Property B: 2N=M2N=M.

Translated by ChatGPT 5