博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Valera and Tubes
阅读量:6195 次
发布时间:2019-06-21

本文共 3075 字,大约阅读时间需要 10 分钟。

C. Valera and Tubes
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 (x1, y1)(x2, y2)...(xr, yr), that:

  • r ≥ 2;
  • for any integer i (1 ≤ i ≤ r - 1) the following equation |xi - xi + 1| + |yi - yi + 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.

Input

The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 3002 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.

Output

Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integersxi1, yi1, xi2, yi2, ..., xiri, yiri (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.

Sample test(s)
input
3 3 3
output
3 1 1 1 2 1 33 2 1 2 2 2 33 3 1 3 2 3 3
input
2 3 1
output
6 1 1 1 2 1 3 2 3 2 2 2 1
Note

Picture for the first sample:

#include 
#include
#include
#define MAXN 100000#define ll long longusing namespace std;int n, m, k, cnt, col, row;int x[MAXN], y[MAXN];int main(void){ int i,j,n,m,k; cin>>n>>m>>k; col=1;row=1;cnt=0; int dir=0; while(cnt
=1) { x[cnt]=row; y[cnt]=col; col--; } else if(col==0) { x[cnt]=row+1; y[cnt]=col+1; row++;col=2; dir=0; } } cnt++; } cnt=0; for(i=0;i
另外 有个比較奇怪的现象,假设把cnt++放在printf里面、測试例如以下:

#include 
#include
#include
#define MAXN 100000#define ll long longusing namespace std;int n, m, k, cnt, col, row;int x[MAXN], y[MAXN];int main(void){ int i,j,n,m,k; cin>>n>>m>>k; col=1;row=1;cnt=0; int dir=0; while(cnt
=1) { x[cnt]=row; y[cnt]=col; col--; } else if(col==0) { x[cnt]=row+1; y[cnt]=col+1; row++;col=2; dir=0; } } cnt++; } cnt=0; for(;cnt
 
 
 
这样就非常easy懂了。由于printf是从右向左编译的,cnt++在,处实现自增。

转载地址:http://mfyca.baihongyu.com/

你可能感兴趣的文章
Vue中注意target和currentTarget的使用
查看>>
如何在windows上调试安卓机谷歌浏览器上的页面
查看>>
iphone-common-codes-ccteam源代码 CCMail.h
查看>>
5,元组
查看>>
Swift基础--Swift中的异常处理
查看>>
也谈谈网页上的微创新(多图:百度、淘宝、腾讯等)
查看>>
深入理解SQL的四种连接-左外连接、右外连接、内连接、全连接(转载)
查看>>
NSOperation 开发
查看>>
二叉排序树
查看>>
毕业随想(转载)
查看>>
8086汇编——课堂笔记整理4
查看>>
小程序开发之改变data中数组或对象的某一属性值
查看>>
asp.net 去掉小数点后面多余的0
查看>>
oracle - sqldeveloper 手动执行包 package的方法
查看>>
高并发、大流量网卡调优 _转
查看>>
如何写3DMAX的插件
查看>>
base64编码
查看>>
jquery.select2 模糊查询
查看>>
viewport
查看>>
【EMC】基本概念
查看>>