CF441C.Valera and Tubes
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).
Valera wants to place exactly k tubes on his rectangle table. A tube is such sequence of table cells (_x_1, _y_1), (_x_2, _y_2), ..., (x__r, y__r), that:
- r ≥ 2;
- for any integer i (1 ≤ i ≤ r - 1) the following equation |x__i - x__i + 1| + |y__i - y__i + 1| = 1 holds;
- each table cell, which belongs to the tube, must occur exactly once in the sequence.
Valera thinks that the tubes are arranged in a fancy manner if the following conditions are fulfilled:
- no pair of tubes has common cells;
- each cell of the table belongs to some tube.
Help Valera to arrange k tubes on his rectangle table in a fancy manner.
瓦列拉有一张由 n 行 m 列组成的矩形表格。瓦列拉将表格的行从上到下编号为 1 至 n,列从左到右编号为 1 至 m。我们将位于第 x 行、第 y 列的单元格表示为整数对 (x,y)。
瓦列拉希望在该矩形表格上恰好放置 k 根“管子”(tube)。一根管子是如下形式的一串表格单元格:(x1,y1), (x2,y2), …, (xr,yr),满足:
- r≥2;
- 对任意整数 i(1≤i≤r−1),均满足 ∣xi−xi+1∣+∣yi−yi+1∣=1;
- 管子所经过的每个表格单元格在该序列中恰好出现一次。
瓦列拉认为,当且仅当满足以下条件时,这些管子的排布方式是“精巧的”(fancy):
- 任意两根管子没有公共单元格;
- 表格中的每个单元格都属于且仅属于某一根管子。
请帮助瓦列拉在他的 n×m 矩形表格上以“精巧的方式”安排 k 根管子。
输入格式
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2_k_ ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
第一行包含三个以空格分隔的整数 n、m、k(2 ≤ n, m ≤ 300;2 ≤ 2k ≤ n⋅m),分别表示行数、列数和管子的数量。
输出格式
Print k lines. In the i-th line print the description of the i-th tube: first print integer r__i (the number of tube cells), then print 2_r__i_ integers _x__i_1, _y__i_1, _x__i_2, _y__i_2, ..., x__ir__i, y__ir__i (the sequence of table cells).
If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution exists.
输出 k 行。在第 i 行中,输出第 i 个管子的描述:首先输出整数 r__i(该管子所占格子数),然后输出 2_r__i_ 个整数 _x__i_1, _y__i_1, _x__i_2, _y__i_2, ..., x__ir__i, y__ir__i(即该管子所覆盖的表格格子坐标序列)。
若存在多种解,输出任意一种即可。题目保证至少存在一个解。
输入输出样例
输入#1
3 3 3
输出#1
3 1 1 1 2 1 3 3 2 1 2 2 2 3 3 3 1 3 2 3 3
输入#2
2 3 1
输出#2
6 1 1 1 2 1 3 2 3 2 2 2 1
说明/提示
Picture for the first sample:

Picture for the second sample:

第一个样例的图片:

第二个样例的图片:

输入解题思路,AI测评打分。不知道怎么写?