QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 100

#6882. 8位缩放

统计

给定一张大小为 $n \times n$ 的图片。你需要以 $Z\%$ 的缩放比例输出“8-bit 风格”的缩放后图片,或者判断该图片无法进行缩放。在 8-bit 风格中,结果图片的大小为 $\frac{nZ}{100} \times \frac{nZ}{100}$。当且仅当满足以下任一条件时,图片无法以 8-bit 风格缩放:

  • $\frac{nZ}{100}$ 不是整数。
  • 在缩放后的图片中,某些像素的颜色无法确定。注意,8-bit 风格不使用任何插值算法,因此当至少两种不同的颜色被映射到结果图片的同一个像素时,该像素的颜色即为无法确定。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10$),表示测试用例的数量。对于每个测试用例:

第一行包含两个整数 $n$ 和 $Z$ ($1 \le n \le 50, 100 \le Z \le 200, Z \pmod{25} = 0$),分别表示原图片的大小和缩放比例。

接下来的 $n$ 行,每行包含一个长度为 $n$ 的字符串,由小写英文字母组成。第 $i$ 行的第 $j$ 个字符表示位于 $(i, j)$ 的像素颜色。

输出格式

对于每个测试用例,如果图片无法缩放,输出一行 error;否则输出 $\frac{nZ}{100}$ 行,每行包含一个长度为 $\frac{nZ}{100}$ 的字符串,表示缩放后的图片。

样例

输入 1

5
2 100
ab
cd
2 200
ab
cd
2 125
aa
aa
4 125
aaab
aaaa
aaaa
aaaa
4 125
aaaa
aaaa
aaaa
aaaa

输出 1

ab
cd
aabb
aabb
ccdd
ccdd
error
error
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.