http://codeforces.com/contest/441/problem/C

题意:有n×m个方格,然后把这些方格分成k部分,每个部分内的方格的坐标满足|xi - xi + 1| + |yi - yi + 1| = 1,且每一个部分内的方格数>=2,输出其中的一种方案。

思路:贪心,先让k-1部分,每一部分占2个方格,依次按照蛇形划分,剩余划分到最后一个内。

 #include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#define maxn 1000100
#define ll long long
using namespace std; int n,m,k;
struct node
{
int x,y;
} st; int main()
{
cin>>n>>m>>k;
vector<node>g[];
int cnt=;
int x=;
for(int i=; i<=n; i++)
{
if(i%)
{
for(int j=; j<=m; j++)
{
cnt++;
st.x=i;
st.y=j;
g[x].push_back(st);
if(x<k-)
{
if(cnt%==)
{
x++;
}
}
}
}
else
{
for(int j=m; j>=; j--)
{
cnt++;
st.x=i;
st.y=j;
g[x].push_back(st);
if(x<k-)
{
if(cnt%==)
{
x++;
}
}
}
}
}
for(int i=; i<k; i++)
{
printf("%d ",(int)g[i].size());
for(int j=; j<(int)g[i].size(); j++)
{
st=g[i][j];
printf("%d %d ",st.x,st.y);
}
printf("\n");
}
return ;
}

codeforces C. Valera and Tubes的更多相关文章

  1. Codeforces 441C Valera and Tubes

    题目链接:Codeforces 441C Valera and Tubes 没看到r >= 2一直错.让前几个管子占用2个格子.最后一个把剩下的都占用了.假设问题有解.这样做一定有解.其它策略就 ...

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

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

  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. photoshopcs5 win7安装报错的解决

    因为之前安装了绿色中文破解版的PhotoShop CS5,虽然卸载了,但是注册表还可能残留了其它信息,导致在安装Adobe PhotoShop CS5英文版时一直显示 (Exit Code: 7 ER ...

  2. [RxJS] Filtering operators: distinct and distinctUntilChanged

    Operator distinct() and its variants are an important type of Filtering operator. This lessons shows ...

  3. 首页在linux下的哪个文件夹

    /data/mindo/tomcat-live/webapps/ROOT/WEB-INF/templates/default/pages/index.jsp   svn检出地址 https://sif ...

  4. 11.1 afternoon

    幸运数字(number)Time Limit:1000ms Memory Limit:64MB题目描述LYK 最近运气很差,例如在 NOIP 初赛中仅仅考了 90 分,刚刚卡进复赛,于是它决定使用一些 ...

  5. 9.28noip模拟试题

    1.栅栏迷宫 田野上搭建了一个黄金大神专用的栅栏围成的迷宫.幸运的是,在迷宫的边界上留出了两段栅栏作为迷宫的出口.更幸运的是,所建造的迷宫是一个“完美的”迷宫:即你能从迷宫中的任意一点找到一条走出迷宫 ...

  6. order by 自定义排序

    使用order by排序,有时候不是根据字符或数字顺序,而是根据实际要求排序. 例如有客户A,B,C,我希望排序结果是B,C,A,那么就要通过自定义的规则排序. 第一种方法,可以构造一张映射表,将客户 ...

  7. 与数据库打交道的Adapter----SimpleCursorAdapter

    http://www.cnblogs.com/wenjiang/p/3196486.html 程序员是这个世界上最神奇的职业,因为几乎所有其他职业的人都能转到该行来,只要他智力正常,有接受过正规的编程 ...

  8. siege安装和使用

    siege(支持http.https).多url. 下载地址:http://www.joedog.org/index/siege-home Cent os系统: 1)./configure 2)mak ...

  9. PHP上传原理及应用

    概要 1.FORM表现enctype属性 2.$_FILES系统函数 3.move_uploaded_file函数 4.is_uploaded_file函数 1.FORM标签的enctype属性 只有 ...

  10. Linux系统下分割tomcat日志

    在Linux系统下,tomcat日志catalina.out并不会像window系统下,按日期进行重写备份,因此在Linux系统下会造成日志文件过大的情况,本文介绍采用 cronolog工具进行如在w ...