题目链接: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的更多相关文章

  1. codeforces 441C. Valera and Tubes 解题报告

    题目链接:http://codeforces.com/problemset/problem/441/C 题目意思:将n * m 的矩阵分成 k 堆.每堆是由一些坐标点(x, y)组成的.每堆里面至少由 ...

  2. codeforces C. Valera and Tubes

    http://codeforces.com/contest/441/problem/C 题意:有n×m个方格,然后把这些方格分成k部分,每个部分内的方格的坐标满足|xi - xi + 1| + |yi ...

  3. Valera and Tubes

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

  4. CodeForces - 369E Valera and Queries(树状数组)

    CodeForces - 369E Valera and Queries 题目大意:给出n个线段(线段的左端点和右端点坐标)和m个查询,每个查询有cnt个点,要求给出有多少条线段包含至少其中一个点. ...

  5. codeforces Round #252 (Div. 2) C - Valera and Tubes

    贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完 由于数据比较小,可以先打表 #include <iostream> #include <vector> #i ...

  6. codeforces 441B. Valera and Fruits 解题报告

    题目链接:http://codeforces.com/problemset/problem/441/B 题目意思:有 n 棵fruit trees,每课水果树有两个参数描述:水果成熟的时间和这棵树上水 ...

  7. codeforces B. Valera and Contest 解题报告

    题目链接:http://codeforces.com/problemset/problem/369/B 题目意思:给出6个整数, n, k, l, r, sall, sk ,需要找出一个满足下列条件的 ...

  8. 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 ...

  9. CodeForces - 369C - Valera and Elections

    369C - Valera and Elections 思路:dfs,对于搜索到的每个节点,看他后面有没有需要修的路,如果没有,那么这个节点就是答案. 代码: #include<bits/std ...

随机推荐

  1. Python面向对象编程 - 一个记事本程序范例(二)

    给程序加上控制台菜单 menu.py import sys from notebook import Notebook, Note class Menu: '''Display a menu and ...

  2. JBOSS启动报错解决方案

    同一个jboss下不可以放不同的项目包,否则报错: 注意:如果后期使用,注意删除上图的本地文件,重新加载即可.

  3. 公众号 - 解决所有测试中的CORS问题

    仅支持GET请求,POST请求会报错. 软件:Chrome 插件:CORS 点击下载 演示:

  4. Android自动填写获取到的验证码

    Android需要添加的相关权限 <uses-permission android:name="android.permission.RECEIVE_SMS">< ...

  5. Zuul使用Ribbon配置自动重试

    spring cloud的版本不断演进,导致很多配置的配置方式不断改变,有时某个配置在一个版本里面默认是true,后边一升级默认成了false,这点让人有点不爽. 言归正传 0.所使用版本 sprin ...

  6. iOS蓝牙BLE4.0通信功能

    概述 iOS蓝牙BLE4.0通信功能,最近刚学的苹果,为了实现蓝牙门锁的项目,找了一天学习了下蓝牙的原理,亲手测试了一次蓝牙的通信功能,结果成功了,那么就把我学习的东西分享一下. 详细 代码下载:ht ...

  7. Chrome 编译错误汇总

    由于各种你懂的原因,訪问google的服务总是出错,先是hosts不工作.代理也不好使,最后最终能够短暂訪问了.我的版本号还是採用svn维护的,直接svn update也不行.试试git吧,一晚上才下 ...

  8. HDUOJ------------1051Wooden Sticks

    Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  9. HDUOJ---(4708)Rotation Lock Puzzle

    Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  10. 将form表单转化为json数据

    参考地址:https://github.com/hongymagic/jQuery.serializeObject