QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 512 MB مجموع النقاط: 100

#12166. Seedlings

الإحصائيات

At the end of March 2018, Mr. Malnar returned from a local family farm with a pile of hot peppers. He easily tied them together with strings in an optimal way and, quite selflessly, shared them with a group of friends. The first to taste them was Dominik, who didn't even feel the heat, then Josip, and so on. However, some of Mr. Malnar's friends were seriously burned. Among them, Krešimir stands out, who vowed to take revenge.

Today, Mr. Malnar no longer buys peppers; he grows them himself. This year, he decided to plant $(N + 1) \cdot (M + 1)$ seedlings in a coordinate system, such that the seedlings are located at integer points from the set $\{0, 1, 2, \dots, N\} \times \{0, 1, 2, \dots, M\}$. Furthermore, he decided to connect the seedlings to each other using $(N + 1)(M + 1) - 1$ pieces of string of unit length; that is, two seedlings can be directly connected by a piece of string if the Euclidean distance between them is 1. Additionally, the seedlings must be connected in such a way that they form a single garland. We say that two seedlings are part of the same garland if a tiny ant, moving exclusively along the seedlings and strings, can travel between the two mentioned seedlings.

An example of a correct connection of seedlings for $N = 1$ and $M = 2$.

Mr. Malnar knows that Krešimir wants to ruin his plans. He sensed that he would come under the cover of night and make exactly one horizontal or vertical cut that would sever every piece of string that gets in his way. It is known that Krešimir will not harm the seedlings themselves, but his cut will be such that the initial garland of seedlings will fall apart into as many garlands as possible.

Therefore, Mr. Malnar will connect the seedlings in such a way that the number of garlands after Krešimir's cut is the smallest possible.

Can you determine one way in which Mr. Malnar could have connected his seedlings?

Input

The first line contains the natural numbers $N$ and $M$ from the problem description.

Output

You need to print $2N + 1$ lines, each with $3M + 1$ characters, representing how the seedlings are connected by pieces of string.

We represent seedlings with the character 'o' (ASCII 111), a piece of string connecting two seedlings in the same column with the character '|' (ASCII 124), and a piece of string connecting two seedlings in the same row with the characters '--' (ASCII 45).

Between adjacent seedlings that are not connected by a piece of string, there are spaces: two space characters (ASCII 32) between seedlings in the same row, and one space character between seedlings in the same column.

Subtasks

Solutions that connect the seedlings in a correct but not optimal way on a test case will earn:

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

points, where $A$ denotes the number of garlands after Krešimir's cut in the optimal solution, $B$ denotes the analogous value in your solution, and $X$ is the number of points assigned to that test case.

The number of points for a subtask is equal to the minimum number of points your solution achieves on any of the test cases in that subtask.

Subtask Points Constraints
1 15 $1 \le N = M \le 1000$
2 15 $2 \le 2N = M \le 1000$
3 5 $1 \le N \le M \le 3$
4 10 $1 \le N \le M \le 10$
5 20 $1 \le N \le M \le 100$
6 35 $1 \le N \le M \le 1000$

Examples

Input 1

2 2

Output 1

o--o o
|  |
o o--o
|  |
o--o--o

Input 2

2 2

Output 2

o--o--o
|
o o--o
|  |
o--o--o

Note

The output of the first example represents one optimal way of connecting the seedlings. Krešimir's cut will break this garland into three smaller garlands.

The output of the second example represents a suboptimal way of connecting the seedlings that Mr. Malnar initially had in mind (note the shape of the letter G). Krešimir's cut will break this garland into four smaller garlands. The number of points you would earn for such an output is 75% of the total number of points assigned to that test case.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.