Codeforces 441C Valera and Tubes
题目链接:Codeforces 441C Valera and Tubes
没看到r >= 2一直错。让前几个管子占用2个格子。最后一个把剩下的都占用了。假设问题有解。这样做一定有解。其它策略就不一定了(比方让某个管子占用了3个格子。而总共同拥有四个格子,两个管子)。
#include <iostream>
#include <cstdio> using namespace std; int main()
{
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
int x = 1, y = 1;
bool flag = false;
for(int i = 0; i < k - 1; i++)
{
printf("2");
for(int j = 0; j < 2; j++)
{
if(!flag)
printf(" %d %d", x, y++);
else
printf(" %d %d", x, y--);
if(y > m)
{
flag = !flag;
x++;
y = m;
}
if(y < 1)
{
flag = !flag;
x++;
y = 1;
}
}
puts("");
}
printf("%d", n * m - ((k - 1) * 2));
while(x <= n)
{
if(!flag)
printf(" %d %d", x, y++);
else
printf(" %d %d", x, y--);
if(y > m)
{
flag = !flag;
x++;
y = m;
}
if(y < 1)
{
flag = !flag;
x++;
y = 1;
}
}
puts("");
return 0;
}
Codeforces 441C Valera and Tubes的更多相关文章
- codeforces 441C. Valera and Tubes 解题报告
题目链接:http://codeforces.com/problemset/problem/441/C 题目意思:将n * m 的矩阵分成 k 堆.每堆是由一些坐标点(x, y)组成的.每堆里面至少由 ...
- codeforces C. Valera and Tubes
http://codeforces.com/contest/441/problem/C 题意:有n×m个方格,然后把这些方格分成k部分,每个部分内的方格的坐标满足|xi - xi + 1| + |yi ...
- Valera and Tubes
C. Valera and Tubes time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CodeForces - 369E Valera and Queries(树状数组)
CodeForces - 369E Valera and Queries 题目大意:给出n个线段(线段的左端点和右端点坐标)和m个查询,每个查询有cnt个点,要求给出有多少条线段包含至少其中一个点. ...
- codeforces Round #252 (Div. 2) C - Valera and Tubes
贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完 由于数据比较小,可以先打表 #include <iostream> #include <vector> #i ...
- codeforces 441B. Valera and Fruits 解题报告
题目链接:http://codeforces.com/problemset/problem/441/B 题目意思:有 n 棵fruit trees,每课水果树有两个参数描述:水果成熟的时间和这棵树上水 ...
- codeforces B. Valera and Contest 解题报告
题目链接:http://codeforces.com/problemset/problem/369/B 题目意思:给出6个整数, n, k, l, r, sall, sk ,需要找出一个满足下列条件的 ...
- CodeForces - 441E:Valera and Number (DP&数学期望&二进制)
Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given belo ...
- CodeForces - 369C - Valera and Elections
369C - Valera and Elections 思路:dfs,对于搜索到的每个节点,看他后面有没有需要修的路,如果没有,那么这个节点就是答案. 代码: #include<bits/std ...
随机推荐
- HttpContext.Current.Cache 和 HttpRuntime.Cache
HttpRuntime.Cache:用于winfrom 和 web HttpContext.Current.Cache 用于web .NET中Cache有两种调用方式:HttpContext.Curr ...
- ZH奶酪:【阅读笔记】Deep Learning, NLP, and Representations
中文译文:深度学习.自然语言处理和表征方法 http://blog.jobbole.com/77709/ 英文原文:Deep Learning, NLP, and Representations ht ...
- 【Linux】关于Linux的部分细节与配置文件
文章对Linux的启动过程 进行了讲解,摘录一些要点,(摘自:https://www.ibm.com/developerworks/cn/linux/l-linuxboot/)如下: 当系统首次引导时 ...
- Java连接Oracle数据库示例
1.数据库复用模块 package cn.jzy.database; import java.sql.Connection; import java.sql.DriverManager; import ...
- 与AQS有关的并发类
ReetrantLock与Condition: 參考 在java.util.concurrent包中.有两个非常特殊的工具类.Condition和ReentrantLock,使用过的人都知道,Reen ...
- 重置outlook 2010
1.进入 D:\program files\mirosoft office\ioffice14 2.outlook /importprf .\.prf 3.账号问题可以-->控制面板--> ...
- jquery选中以什么开头的元素
$("[id^=percent]").size() ^=:表示以什么开头 $=:表示以什么结尾 ~=:表示包含什么 id:表示按id选择
- 〖Linux〗Ubuntu13.10中使用虚拟机对MTK手机进行线刷
最近一个同学把一台MTK手机刷坏了,在我的笔记本电脑上没有WindowsXp操作系统: 而在MTK线刷过程中,最好的刷机系统便是WindowsXP3,于是有了想在Linux中直接开启XP虚拟机来刷机的 ...
- python学习笔记之函数(方法)
def func(x): print 'x is', x x = 2 print 'Changed local x to', x x = 50 func(x) print 'x is still', ...
- springmvc json结合
获取json数据 名字一样就获取了 user @RequestMapping("/addUser") public String addUser(User user,Htt ...