CF432E.Square Tiling
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have an n × m rectangle table, its cells are not initially painted. Your task is to paint all cells of the table. The resulting picture should be a tiling of the table with squares. More formally:
- each cell must be painted some color (the colors are marked by uppercase Latin letters);
- we will assume that two cells of the table are connected if they are of the same color and share a side; each connected region of the table must form a square.
Given n and m, find lexicographically minimum coloring of the table that meets the described properties.
你有一个 n×m 的矩形表格,其单元格初始时未被涂色。你的任务是将表格的所有单元格全部涂色,使得最终图案构成该表格的一个正方形铺砌(tiling with squares)。更准确地说:
- 每个单元格必须被涂上某种颜色(颜色用大写拉丁字母表示);
- 若两个单元格颜色相同且共享一条边,则称它们连通;每个由同色单元格构成的连通区域必须恰好形成一个正方形。
给定 n 和 m,请找出满足上述性质的字典序最小的涂色方案。
输入格式
The first line contains two integers, n and m (1 ≤ n, m ≤ 100).
第一行包含两个整数 n 和 m(1≤n,m≤100)。
输出格式
Print lexicographically minimum coloring of the table that meets the described conditions.
One coloring (let's call it X) is considered lexicographically less than the other one (let's call it Y), if:
- consider all the table cells from left to right and from top to bottom (first, the first cell in the first row, then the second cell in the first row and so on);
- let's find in this order the first cell that has distinct colors in two colorings;
- the letter that marks the color of the cell in X, goes alphabetically before the letter that marks the color of the cell in Y.
输出满足上述条件的字典序最小的表格染色方案。
一种染色方案(记为 X)被称为字典序小于另一种染色方案(记为 Y),当且仅当:
- 按从左到右、从上到下的顺序遍历所有表格单元格(即先第一行的第一个单元格,再第一行的第二个单元格,依此类推);
- 按此顺序找到第一个在两种染色方案中颜色不同的单元格;
- 在该单元格处,X 中所用颜色对应的字母在字母表中位于 Y 中所用颜色对应字母之前。
输入输出样例
输入#1
1 3
输出#1
ABA
输入#2
2 2
输出#2
AA AA
输入#3
3 4
输出#3
AAAB AAAC AAAB
输入解题思路,AI测评打分。不知道怎么写?