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 ≤ 300; 2 ≤ 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 3
3 2 1 2 2 2 3
3 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:

Picture for the second sample:

解题报告
让每一个人两个,剩下给第一个
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std;
int mmap[310][310];
int main()
{
int n,m,k;
while(cin>>n>>m>>k)
{
int t=n*m-(k-1)*2;
int x=1,y=1;
printf("%d",t);
while(t--)
{
printf(" %d %d",x,y);
mmap[x][y]=1;
if(y+1<=m&&!mmap[x][y+1])
{
y++;
}
else if(y-1>=1&&!mmap[x][y-1])
y--;
else x++;
}
k--;
while(k--)
{
printf("\n2");
t=2;
while(t--)
{
printf(" %d %d",x,y);
mmap[x][y]=1;
if(y+1<=m&&!mmap[x][y+1])
{
y++;
}
else if(y-1>=1&&!mmap[x][y-1])
y--;
else x++;
}
}
printf("\n");
}
}

Codeforces441C_Valera and Tubes(暴力)的更多相关文章

  1. zone.js - 暴力之美

    在ng2的开发过程中,Angular团队为我们带来了一个新的库 – zone.js.zone.js的设计灵感来源于Dart语言,它描述JavaScript执行过程的上下文,可以在异步任务之间进行持久性 ...

  2. [bzoj3123][sdoi2013森林] (树上主席树+lca+并查集启发式合并+暴力重构森林)

    Description Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数 ...

  3. HDU 5944 Fxx and string(暴力/枚举)

    传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Othe ...

  4. 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)

    湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...

  5. fragment+viepager 的简单暴力的切换方式

    这里是自定义了一个方法来获取viewpager private static ViewPager viewPager; public static ViewPager getMyViewPager() ...

  6. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  7. uoj98未来程序改 纯暴力不要想了

    暴力模拟A了,数据还是良(shui)心(shui)的 90分的地方卡了半天最后发现一个局部变量被我手抖写到全局去了,,, 心碎*∞ 没什么好解释的,其实只要写完表达式求值(带函数和变量的),然后处理一 ...

  8. 开源服务专题之------ssh防止暴力破解及fail2ban的使用方法

    15年出现的JAVA反序列化漏洞,另一个是redis配置不当导致机器入侵.只要redis是用root启动的并且未授权的话,就可以通过set方式直接写入一个authorized_keys到系统的/roo ...

  9. 关于csrss.exe和winlogon.exe进程多、占用CPU高的解决办法,有人在暴力破解

    关于csrss.exe和winlogon.exe进程多.占用CPU高的解决办法 最近VPS的CPU一直处在100%左右,后台管理上去经常打不开,后来发现上远程都要好半天才反映过来,看到任务管理器有多个 ...

随机推荐

  1. PS 如何制作球面化文字效果

    球面化文字效果图....   00newopen-a   00newopen-b     01mew+channel   02ctrl+L   03ctrl+I   04new+wenzi   05R ...

  2. 安全狗两个中危提权+NET提权

    1.循环加组复现 for /l %%i in (1,1,1000) do @net user admin admin /add&@ net localgroup administrators  ...

  3. Laravel利用pusher推送消息

    一.注册pusher 1.注册https://pusher.com/ 2.获取key,密匙,app_id等 二.配置pusher 1.安装pusher composer require pusher/ ...

  4. vue-router 动态路由匹配

    export default new Router({ routes: [ { path: '/', name: 'HelloWorld', component: HelloWorld, }, { / ...

  5. .net用url重写URLReWriter实现任意二级域名

    .net用url重写URLReWriter实现任意二级域名 这两天需要用到URLReWriter来搞那个猪头的Blog,网上看到篇好文,收藏 摘要:解释了url重写的相关知识.用asp.net实现二级 ...

  6. linux下的3种DDOS软件介绍

    什么是TFN2K? TFN2K 的作者是著名的德国黑客mixter. http://mixter.void.ru/papers.html TFN2K通过主控端利用大量代理端主机的资源进行对一个或多个目 ...

  7. fedora20配置静态ip

    在linux的世界里.给主机设置固定ip是这么做的(使用root用户): 1.查看要配的网络接口 用ifconfig查看查看在用的网卡接口,一般都用第一个如:eth0,en1,em1等 2.停用网络自 ...

  8. maven的一些基础命令

    1.显示当前构建的实际pom,包括活动的Profile mvn help:effective-pom 2.打印出项目的世界settings,包含从全局的settings和用户级别settings继承的 ...

  9. python .py .pyc .pyw .pyo .pyd区别

    .py 文件 以 .py 作扩展名的文件是 Python 源代码文件,由 python.exe 解释,可在控制台下运行.当然,也可用文本编辑器进行修改. .pyc 文件 以 .pyc 作扩展名的文件是 ...

  10. Error in as.POSIXlt.character(x, tz, ...) :

    > sqlFetch(channel,"user")Error in as.POSIXlt.character(x, tz, ...) :   character strin ...