A9517 | Valera and Tubes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains three space-separated integers $n,m,k$ ( $2<=n,m<=300$ ; $2<=2k<=n·m$ ) — the number of rows, the number of columns and the number of tubes, correspondingly.
输出格式
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 $2r_{i}$ integers $x_{i1},y_{i1},x_{i2},y_{i2},...,x_{iri},y_{iri}$ (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.
If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution exists.
输入输出样例
输入 #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:

Picture for the second sample:

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted