P7218 [JOISC 2020] The Legendary Dango Skewer Master

Background

You are a dango skewer master, and you are very strong.

Description

In front of you is an $R \times C$ grid. Each cell contains one dango. You may skewer three consecutive dango in order in a horizontal, vertical, or diagonal direction. “In order” means you may skewer them as top-middle-bottom, bottom-middle-top, etc., but you may not skewer them as middle-bottom-top, top-bottom-middle, etc. If the colors of a skewered triple are green, white, pink or pink, white, green, then this triple is called an AK IOI skewer. Find a way to skewer as many AK IOI skewers as possible (I firmly believe that making several AK IOI skewers will let you AK IOI several times).

Input Format

The first line contains two integers $R, C$ representing the grid size. Then follow $R$ lines, each containing $C$ characters representing the grid: - `P` represents a pink dango. - `W` represents a white dango. - `G` represents a green dango.

Output Format

Output $R$ lines, each containing $C$ characters representing the skewered grid: - It may be `-`, `|`, `/`, `\`, representing a skewer passing through a dango. - If it is not one of the above four symbols, output it as-is. The output files should be `01.ans` ~ `06.ans`.

Explanation/Hint

#### Sample 1 Explanation You made $3$ AK IOI skewers. #### Sample 2 Explanation You made $2$ AK IOI skewers. #### Constraints **This is an output-only problem.** **This problem uses Special Judge.** There are $6$ testdata. It is guaranteed that $3 \le R, C \le 500$. The input files can be obtained from the attachment. The detailed table is as follows: |Test case|Score $S$|Pass line $X$|Good line $Y$|Excellent line $Z$| |:-:|:-:|:-:|:-:|:-:| |$1$|$15$|$44000$|$47000$|$47220$| |$2$|$15$|$39000$|$41700$|$41980$| |$3$|$15$|$45000$|$51000$|$51390$| |$4$|$15$|$18000$|$19000$|$19120$| |$5$|$20$|$43000$|$48200$|$48620$| |$6$|$20$|$44000$|$46000$|$46500$| Suppose $N$ is the number of AK IOI skewers you obtain. Then the scoring rule is (rounded to the nearest integer): - If $N < X$, then $0$ points. - If $X \le N < Y$, then $\dfrac{N-X}{2(Y-X)} \times S$ points. - If $Y \le N < Z$, then $\left(\dfrac{1}{2}+\dfrac{N-Y}{2(Z-Y)}\right) \times S$ points. - If $Z \le N$, then $S$ points. If the output format is incorrect or the output is invalid, you will receive $0$ points. #### Notes Translated from [The 19th Japanese Olympiad in Informatics Spring Training Camp](https://www.ioi-jp.org/camp/2020/2020-sp-tasks/index.html) [Day 4 B The Legendary Dango Skewer Master](https://www.ioi-jp.org/camp/2020/2020-sp-tasks/day4/dango2.pdf). Translated by ChatGPT 5