Codeforces441C_Valera and Tubes(暴力)
1 second
256 megabytes
standard input
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.
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 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.
3 3 3
3 1 1 1 2 1 3
3 2 1 2 2 2 3
3 3 1 3 2 3 3
2 3 1
6 1 1 1 2 1 3 2 3 2 2 2 1
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(暴力)的更多相关文章
- zone.js - 暴力之美
在ng2的开发过程中,Angular团队为我们带来了一个新的库 – zone.js.zone.js的设计灵感来源于Dart语言,它描述JavaScript执行过程的上下文,可以在异步任务之间进行持久性 ...
- [bzoj3123][sdoi2013森林] (树上主席树+lca+并查集启发式合并+暴力重构森林)
Description Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数 ...
- HDU 5944 Fxx and string(暴力/枚举)
传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Othe ...
- 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)
湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...
- fragment+viepager 的简单暴力的切换方式
这里是自定义了一个方法来获取viewpager private static ViewPager viewPager; public static ViewPager getMyViewPager() ...
- 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 ...
- uoj98未来程序改 纯暴力不要想了
暴力模拟A了,数据还是良(shui)心(shui)的 90分的地方卡了半天最后发现一个局部变量被我手抖写到全局去了,,, 心碎*∞ 没什么好解释的,其实只要写完表达式求值(带函数和变量的),然后处理一 ...
- 开源服务专题之------ssh防止暴力破解及fail2ban的使用方法
15年出现的JAVA反序列化漏洞,另一个是redis配置不当导致机器入侵.只要redis是用root启动的并且未授权的话,就可以通过set方式直接写入一个authorized_keys到系统的/roo ...
- 关于csrss.exe和winlogon.exe进程多、占用CPU高的解决办法,有人在暴力破解
关于csrss.exe和winlogon.exe进程多.占用CPU高的解决办法 最近VPS的CPU一直处在100%左右,后台管理上去经常打不开,后来发现上远程都要好半天才反映过来,看到任务管理器有多个 ...
随机推荐
- C++ 设置控制台输出颜色
#include <stdint.h> #include <iostream> #include <string> #include <Windows.h&g ...
- S4:装饰模式 Decorator
动态的给一个对象添加额外的一些职责,就增加功能而言,比继承更具灵活性. 如果仅有一个ConcreateComponent,也可以让Decorator继承ConcreateComponent来实现装饰功 ...
- 最美应用-从Android研发project师的角度之[最美时光]
最美应用-从Android研发project师的角度之最美时光 @author ASCE1885的 Github 简书 微博 CSDN 近期发现最美应用这样一个站点.它会定期推介一些非常有意思的app ...
- DNS检测
dig @58.241.41.152 6900255264940.barcode.cniotroot.cn naptr 没有naptr 好像有点异常 select count(*) as total ...
- 工作总结 获取html 标签 自定义属性值 根据html 自定义属性 获取 到标签
FFID HFID function getElementByAttr(tag, attr, value) { var aElements = document.getElementsByTag ...
- Godaddy域名 绑定ip 服务器
比如我的域名是wmxl.info 第一个红框代表wmxl.info 绑定的 211.83.110.216 第一个代表www.wmxl.info 绑定的 211.83.110.216, 你也可以换一个服 ...
- JAVA实现EXCEL公式专题(七)——统计函数
统计函数主要实现的是较为复杂的统计函数如countif.sumif.frequency,也是,直接上代码 /** * 项目名称: * 文件说明: * 主要特点:文件说明:EXCEL函数类型:统计函数 ...
- MQTT服务器搭建--Apollo
尊重原创,我是伸手党:https://blog.csdn.net/u012377333/article/details/68943416 1.Apollo下载 下载地址:http://activemq ...
- Ubuntu16.04下搜狗输入法、Sublime Text 3的安装
Ubuntu16.04下搜狗输入法.Sublime Text 3的安装 一.搜狗输入法 1. 安装中文语言 默认在Ubuntu16.04下是没有中文的,需要安装中文,在System Settings- ...
- eclipse导入svn工程,在文件夹里面不展示svn工程图标
原因:没有安装subclipse插件 解决方法:在marketplace中搜索插件名字:subclipse,点击安装,或者在instal new software中输入插件名字,安装完成之后,在文件夹 ...