/
Time Limit: 2 sec / Memory Limit: 1024 MiB
表示言語
/ /Score : 100 points
Problem Statement
Haru_101 prepared an N \times N grid-shaped garden for SCSC. Every spring, SCSC members have a beautiful tradition of planting one flower in each cell. This year, they decided to plant sunflowers and clovers.
After all flowers were planted, Terra and Lulu looked around the garden and gave different impressions.
Terra looked down at the whole garden from a high place and said: "Looking at the whole garden, there are more cells planted with blue clovers than yellow sunflowers!"
Lulu likes taking photos, so Lulu walked around the garden and took photos of size 3 \times 3. After taking photos of every 3 \times 3 area in the garden without omission, Lulu looked at the photos and said: "Huh? In every photo I took, there are more sunflowers than clovers!"
Can you make a magical garden where, as Terra said, the whole garden has more clovers, but every photo Lulu took has more sunflowers?
Constraints
- 1 \leq T \leq 1\,000
- For each test case, 3 \leq N \leq 1\,000.
- All given numbers are integers.
- Only cases where the output does not exceed 2 MiB are given.
Input
The input is given from Standard Input in the following format:
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
Each test case is given in the following format:
N
Output
For each test case, output the answer in the following format.
If it is possible to make a magical garden, output YES on the first line.
Then output N lines, each containing a string of length N representing the state of the garden. Each string must consist only of S and C. The j-th character of the i-th string must be S if the flower planted in cell (i,j) of the garden is a sunflower, and C if it is a clover. In every 3 \times 3 subgrid of the grid, the number of S must be greater than the number of C, and in the whole grid, the number of C must be greater than the number of S.
If there are multiple magical gardens, output any one of them.
If it is impossible to make a magical garden, output NO on a single line instead.
Sample Input 1
1 3
Sample Output 1
NO
Sample Input 2
1 4
Sample Output 2
YES CCSC CSSC CSSC CCSC
表示言語
/ /Score : 100 points
문제
Haru_101은 SCSC에 N \times N 크기의 격자 모양 화원을 마련했다. SCSC 회원들은 매년 봄마다 각 칸에 꽃을 하나씩 심는 아름다운 전통이 있다. 올해는 해바라기와 클로버를 심기로 했다.
모든 꽃을 심고 난 뒤 화원을 구경하던 테라와 루루는 서로 다른 감상을 남겼다.
테라는 높은 곳에서 화원 전체를 한눈에 내려다보며 감상하며 말했다. "전체적으로 보니 노란 해바라기보다는 푸른 클로버가 심어진 칸이 더 많네!"
루루는 사진 찍는 것을 좋아하기 때문에 화원 구석구석을 돌아다니며 3 \times 3 크기의 사진을 촬영했다. 루루는 화원에 존재하는 모든 3 \times 3 영역을 빠짐없이 촬영한 뒤 찍은 사진을 보며 말했다. "어? 내가 찍은 어떤 사진을 봐도 그 안에는 해바라기가 클로버보다 많은데?"
테라의 말대로 화원 전체에는 클로버가 더 많지만 루루가 찍은 어떤 사진을 보더라도 해바라기가 더 많은 마법 같은 화원을 만들 수 있을까?
제한
- 1 \leq T \leq 1\,000
- 3 \leq N \leq 1\,000
- 입력으로 주어지는 수는 모두 정수이다.
- 출력이 2 MiB를 넘지 않는 경우만 주어진다.
입력
입력은 다음 형식으로 표준 입력으로 주어진다.
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
각 테스트 케이스는 다음 형식으로 주어진다.
N
출력
각 테스트 케이스마다 다음 형식으로 답을 출력한다.
마법 같은 화원을 만들 수 있다면 첫째 줄에 YES를 출력한다.
둘째 줄부터 N개의 줄에 걸쳐 S와 C로만 이루어진 길이 N의 문자열을 출력한다. 그중 i번째 문자열의 j번째 문자는 화원의 i 행 j 열에 심어진 꽃이 해바라기라면 S, 클로버라면 C여야 한다. 이때 격자의 모든 3 \times 3 부분격자에 있는 S의 개수가 C의 개수보다 많아야 하며, 전체 격자에 있는 C의 개수가 S의 개수보다 많아야 한다.
마법 같은 화원이 여러 가지 존재한다면 그중 아무거나 출력해도 된다.
마법 같은 화원을 만드는 것이 불가능하다면 대신 NO를 출력한다.
입력 예 1
1 3
출력 예 1
NO
입력 예 2
1 4
출력 예 2
YES CCSC CSSC CSSC CCSC
表示言語
/ /配点 : 100 点
問題文
Haru_101 は SCSC に N \times N の格子状の花園を用意した.SCSC の会員たちには,毎年春に各マスへ花を 1 つずつ植える美しい伝統がある.今年はヒマワリとクローバーを植えることにした.
すべての花を植えた後,花園を見物していたテラとルルは互いに異なる感想を残した.
テラは高いところから花園全体を一目で見下ろしながら言った.「全体的に見ると,黄色いヒマワリより青いクローバーが植えられたマスの方が多いね!」
ルルは写真を撮るのが好きなので,花園の隅々を歩き回りながら 3 \times 3 の写真を撮影した.ルルは花園に存在するすべての 3 \times 3 領域を漏れなく撮影した後,撮った写真を見ながら言った.「あれ?私が撮ったどの写真を見ても,その中にはヒマワリの方がクローバーより多いよ?」
テラの言葉通り花園全体にはクローバーの方が多いが,ルルが撮ったどの写真を見てもヒマワリの方が多い,魔法のような花園を作ることはできるだろうか?
制約
- 1 \leq T \leq 1\,000
- 各テストケースにおいて,3 \leq N \leq 1\,000
- 入力される数値はすべて整数である.
- 出力が 2 MiB を超えない場合のみ与えられる.
入力
入力は以下の形式で標準入力から与えられる.
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
各テストケースは次の形式で与えられる.
N
出力
各テストケースについて,次の形式で答えを出力せよ.
魔法のような花園を作れるなら,最初の行に YES を出力する.
続いて N 行にわたり,花園の状態を表す長さ N の文字列を出力する.各文字列は S と C のみからならなければならず,i 番目の文字列の j 番目の文字は,花園のマス (i,j) に植えられた花がヒマワリなら S,クローバーなら C を出力しなければならない.このとき,格子のすべての 3 \times 3 部分格子で S の個数は C の個数より多くなければならず,格子全体で C の個数は S の個数より多くなければならない.
魔法のような花園が複数存在するなら,そのうちどれを出力してもよい.
魔法のような花園を作ることが不可能なら,代わりに NO を 1 行に出力する.
入力例 1
1 3
出力例 1
NO
入力例 2
1 4
出力例 2
YES CCSC CSSC CSSC CCSC