Codeforces Round 749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1)
I
Omkar and Mosaic
Codeforces
3500
原题
← H→
翻译中…

Omkar is creating a mosaic using colored square tiles, which he places in an $n \times n$ grid. When the mosaic is complete, each cell in the grid will have either a glaucous or sinoper tile. However, currently he has only placed tiles in some cells.

翻译中…

A completed mosaic will be a mastapeece if and only if each tile is adjacent to exactly $2$ tiles of the same color ($2$ tiles are adjacent if they share a side.) Omkar wants to fill the rest of the tiles so that the mosaic becomes a mastapeece. Now he is wondering, is the way to do this unique, and if it is, what is it?

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \leq n \leq 2000$).

翻译中…

Then follow $n$ lines with $n$ characters in each line. The $i$-th character in the $j$-th line corresponds to the cell in row $i$ and column $j$ of the grid, and will be $S$ if Omkar has placed a sinoper tile in this cell, $G$ if Omkar has placed a glaucous tile, $.$ if it's empty.

翻译中…

Output

翻译中…

On the first line, print UNIQUE if there is a unique way to get a mastapeece, NONE if Omkar cannot create any, and MULTIPLE if there is more than one way to do so. All letters must be uppercase.

翻译中…

If you print UNIQUE, then print $n$ additional lines with $n$ characters in each line, such that the $i$-th character in the $j^{\text{th}}$ line is $S$ if the tile in row $i$ and column $j$ of the mastapeece is sinoper, and $G$ if it is glaucous.

翻译中…

Note

翻译中…

For the first test case, Omkar can make the mastapeeces

翻译中…

SSSS

翻译中…

SGGS

翻译中…

SGGS

翻译中…

SSSS

翻译中…

and

翻译中…

SSGG

翻译中…

SSGG

翻译中…

GGSS

翻译中…

GGSS.

翻译中…

For the second test case, it can be proven that it is impossible for Omkar to add tiles to create a mastapeece.

翻译中…

For the third case, it can be proven that the given mastapeece is the only mastapeece Omkar can create by adding tiles.

翻译中…

For the fourth test case, it's clearly impossible for the only tile in any mosaic Omkar creates to be adjacent to two tiles of the same color, as it will be adjacent to $0$ tiles total.

翻译中…

样例

Input #1
4
S...
..G.
....
...S
Output #1
MULTIPLE
InputCopy OutputCopy
Input #2
6
S.....
....G.
..S...
.....S
....G.
G.....
Output #2
NONE
InputCopy OutputCopy
Input #3
10
.S....S...
..........
...SSS....
..........
..........
...GS.....
....G...G.
..........
......G...
..........
Output #3
UNIQUE
SSSSSSSSSS
SGGGGGGGGS
SGSSSSSSGS
SGSGGGGSGS
SGSGSSGSGS
SGSGSSGSGS
SGSGGGGSGS
SGSSSSSSGS
SGGGGGGGGS
SSSSSSSSSS
InputCopy OutputCopy
Input #4
1
.
Output #4
NONE
InputCopy OutputCopy
题目信息
题号
1586I
时间限制
2 s
内存限制
256 MB
标签
组合数学
构造
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。