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 ...
随机推荐
- eclipse开发php的插件
php development tools,简称pdt,在Eclipse marketplace里面可以下载到.
- STL - 容器 - Map(一)
MapTest.cpp #include <map> #include <string> #include <iostream> #include <algo ...
- awk的使用
http://www.cnblogs.com/chengmo/archive/2010/10/08/1845913.html linux awk 内置函数详细介绍(实例) awk内置字符串函数 awk ...
- IOS学习笔记45--UITableView性能优化
说实话,面试的时候已经被问到几次这个问题,然后就搜索了一下,看到了这篇优化文章,感觉不错,转来日后作为一种UITableView优化的方法. 使用不透明视图. 不透明的视图可以极大地提高渲染 ...
- dos下遍历目录和文件的代码(主要利用for命令)(转)
===== 文件夹结构 ============================================= D:\test ---A Folder 1 |-----A file 1.txt | ...
- js 判断iframe是否加载完毕
js 判断iframe是否加载完毕 CreationTime--2018年9月13日15点30分 Author:Marydon 1.javascript实现 window.onload = fun ...
- S3 服务(Simple Storage Service简单存储服务) 简介(与hdfs同一级)
图1 spark 相关 亚马逊云存储之S3(Simple Storage Service简单存储服务) (转 ) S3是Simple Storage Service的缩写,即简单存储服务.亚马逊的名 ...
- 一些很经典的JavaScript的问题
1.作用域 (function() { var a = b = 5; })(); console.log(b); 输出:5 陷阱是,在函数表达式中有两个赋值,但a是用关键字var 来声明的,这意味着a ...
- JavaScript-jQuery插件开发全解析
摘自:http://www.iteye.com/topic/545971 jQuery插件的开发包括两种: 一种是类级别的插件开发,即给jQuery添加新的全局函数,相当于给jQuery类本身添加方法 ...
- 【LeetCode】45. Jump Game II
Jump Game II Given an array of non-negative integers, you are initially positioned at the first inde ...