問題一覧 > 通常問題

No.3731 Kaleidoscope

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 34
作問者 : 👑 kencho / テスター : uruzunyaa 👑 p-adic
お気に入りにしたユーザー ProblemId : 13614 / 自分の提出
問題文最終更新日: 2026-11-02 04:27:39
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
グリッド構築24題 (順位表) の他の問題:

Problem Statement

Output $1$ example of an $N \times N$ grid, with each cell painted white or black, that satisfies all of the following conditions. Note that the grid size $N$ is not given in the input, and you may choose it freely.

  • $2 \leq N \leq 2^{10}$
  • Cells $(1, 1)$ and $(N, N)$ are painted white.
  • For $1 \leq i \leq |S|$, if the $i$-th character of the string $S$ is o, there exists a path from cell $(1,1)$ to $(N,N)$, formed by repeatedly moving to an adjacent white cell to the right or downward, that turns $i$ times along the way.
  • For $1 \leq i \leq |S|$, if the $i$-th character of the string $S$ is x, there does not exist a path from cell $(1,1)$ to $(N,N)$, formed by repeatedly moving to an adjacent white cell to the right or downward, that turns $i$ times along the way.

Here, $|S|$ denotes the length of the string $S$.

A path "turns $i$ times along the way" means that, among the moves on the path (excluding the first one), exactly $i$ moves have a direction (right or down) different from that of the immediately preceding move.

It does not matter whether paths with more than $|S|$ turns exist.

If no grid satisfying the conditions exists, output -1.

Constraints

  • $S$ is a string consisting of o and x
  • $1 \leq |S| \leq 1000$

Input

The input is given from standard input in the following format.

$S$

Output

If a painting satisfying the conditions exists, output one example in the following format. Here, $T_i\ (1 \leq i \leq N)$ is a string of length $N$, and the $j$-th character of $T_i$ must be . if the cell in the $i$-th row from the top and the $j$-th column from the left is painted white, and # if it is painted black.

$N$
$T_1$
$T_2$
$\vdots$
$T_N$

If no painting satisfying the conditions exists, output -1.

Print a newline at the end.

Visualizer

A web-based visualizer for the output is available here.

Please note that during the contest, sharing visualization results and mentioning solutions or insights are prohibited.

In principle, questions about the visualizer's specifications will not be accepted. Please use it only as an auxiliary tool.

Sample

Sample 1
Input
oxo
Output
3
.##
..#
...

An example of a path that turns $1$ time along the way is $(1, 1) \rightarrow (2, 1) \rightarrow (3, 1) \rightarrow (3, 2) \rightarrow (3, 3)$.

There is no path that turns $2$ times along the way.

An example of a path that turns $3$ times along the way is $(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (3, 2) \rightarrow (3, 3)$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。