当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3732:Paint Me Less

Special Judge 特殊评判
题目描述

Alice likes drawing very much. But, maybe, precisely speaking, she just loves painting a sheet of paper into a single color. Today she gets a paper with some colors on it and she starts to paint it all black. The rectangular paper is divided into several rows and columns. Each block, with a single color, is connected to four other blocks which are the blocks directly upper, lower, left or right to it. All the blocks with the same color and connected to each other forms a region. Every time Alice paints, she chooses one region and paint all blocks of that region with a same color, which counted as a step. Unfortunately, Alice is not good at math. And she always paints a lot of times which makes her tired and unhappy. Could you help her painting in an easy way?

输入解释

The input file contains multiple cases until the end of file. The first line of each case consists of two integers, R and C (1≤R≤4, 1≤C≤4), which stands for the number of rows and columns of the paper. There are R lines follows which describes the original paper. Each line contains C integers, which the j-th integer of the i-th line describes the color of block (i,j) (1≤i≤R, 1≤j≤C).

Colors are represented by integers in the range [0, 19]. And the target color, which Alice wants to paint the whole paper into, is zero.

输出解释

For each test case, print an integer S, the minimal steps Alice must paint, on the first line. Then describe your solution in the following S lines in this format:
x1 y1 c1
x2 y2 c2
...
xS yS cS
That means at step i Alice should paint the whole region containing block (xi,yi) into color ci.

输入样例
2 2
3 1
1 1
输出样例
2
1 2 3
2 2 0

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3732

最后修改于 2020-10-29T07:09:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000 65536