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. php装饰器

    <?php /* * 用一个类来装饰另一个类,动态的给一个对象增加一些额外功能,这些功能一般是在这个对象调用方法前或方法后 * 比如我们要给User类增加一个登陆日志的功能 */ // 抽象构件 ...

  2. C++11之function模板和bind函数适配器

    在C++98中,可以使用函数指针,调用函数,可以参考之前的一篇文章:类的成员函数指针和mem_fun适配器的用法.   简单的函数调用   对于函数: void foo(const string &a ...

  3. STL学习笔记(迭代器类型)

    迭代器类型 迭代器是一种“能够遍历某个序列内的所有元素”的对象.它可以透过与一般指针一致的接口来完成自己的工作. 不同的迭代器具有不同的”能力“(行进和存取能力) Input迭代器 Input迭代器只 ...

  4. document.querySelector()与document.querySelectorAll()

      document.querySelector()与document.querySelectorAll() CreationTime--2018年7月1日10点49分 Author:Marydon ...

  5. 【VBA】获取Excle的安装路径

    在VBA中,如何获取Excle的安装路径呢?请看以下代码: Sub 获取Excle的安装路径() MsgBox "Excle的安装路径为:" & Application.P ...

  6. json对象和json字符串之间的转换-JavaScript实现

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  7. 【LeetCode-面试算法经典-Java实现】【030-Substring with Concatenation of All Words(串联全部单词的子串)】

    [030-Substring with Concatenation of All Words(串联全部单词的子串)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Yo ...

  8. NFS网络文件系统服务(配置实战)

    NFS网络文件系统服务(实战) NFS(Network File System)即网络文件系统,它允许网络中的计算机之间通过TCP/IP网络共享资源.让不同的主机系统(NFS的客户端)可以透明地读写位 ...

  9. tcp 状态转移图详解

    首先看一张图片: 虚线表示服务端的状态转移,实现表示客户端的状态转移. 初始的close状态并不是真是的状态,只是为了方便描述开始和终止状态而构造出来的. 从服务端的状态转移开始说: 服务端打开后处于 ...

  10. C++中多态性学习(上)

    多态性学习(上) 什么是多态? 多态是指同样的消息被不同类型的对象接收时导致不同的行为.所谓消息是指对类的成员函数的调用,不同的行为是指不同的实现,也就是调用了不同的函数.虽然这看上去好像很高级的样子 ...