問題一覧 > 通常問題

No.3232 Not Tic Tac Toe

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 113
作問者 : YY-otter / テスター : Arleen tatesoto
お気に入りにしたユーザー ProblemId : 11134 / 自分の提出
問題文最終更新日: 2025-08-15 01:40:25
Not Tic Tac Toe
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. Show the original
yukicoder contest 478 オムニバス (順位表) の他の問題:

Problem Statement

You are given positive integers $H,W$.
Output one board with $H$ rows and $W$ columns that satisfies the following conditions.
It can be proved that, under the constraints above, a board satisfying the following conditions always exists.

Conditions:
  • Every cell is either O or X (both are uppercase English letters).
  • Neither O nor X appears $3$ or more times consecutively in a vertical, horizontal, or diagonal line.
    More precisely, let $c_{x,y}(1\leq x\leq W,1\leq y\leq H)$ be the character in the cell that is $x$-th from the left and $y$-th from the top.
    Then, there exists no pair $(x,y)$ satisfying any of the following.
    • $x\leq W-2$ and $c_{x,y}=c_{x+1,y}=c_{x+2,y}$
    • $y\leq H-2$ and $c_{x,y}=c_{x,y+1}=c_{x,y+2}$
    • $x\leq W-2,y\leq H-2$ and $c_{x,y}=c_{x+1,y+1}=c_{x+2,y+2}$
    • $x\leq W-2,y\leq H-2$ and $c_{x,y+2}=c_{x+1,y+1}=c_{x+2,y}$

Input

$H\ W$
  • $1\leq H,W\leq 3000$
  • All inputs are integers.

Output

Output a board satisfying the conditions as $H$ lines, each with $W$ characters (see the sample outputs for details).
Print a newline at the end.

Sample

Sample 1
Input
3 3
Sample Output
XOO
OXX
OXO

This sample output represents the board shown in the image below.

In this board, every cell is either O or X, and neither O nor X appears $3$ or more times consecutively, so the conditions are satisfied.
Other boards satisfying the conditions also exist, but you should output any one of them.

Sample 2
Input
3 4
Sample Output
XOXO
XOOX
OXOX

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