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. cubietruck+ vncserver+source+wlan0 分类: cubieboard 2014-11-08 17:25 159人阅读 评论(0) 收藏

    正常ubuntu下直接搜索remote desktop 进行配置,好用而且友好.. modprobe bcmdhd lsmod ifconfig wlan0 up vi /etc/network/in ...

  2. RGB的三维模型与渐变色-颜色系列之一

    一.前言 以下与颜色相关的日志记录了俺学习颜色的有关容,限于编写时的水平,难免存在缺点与错误,希望得到朋友.同行和前辈的指教,非常感谢.1.  RGB的三维模型与渐变色-颜色系列之一2.  <颜 ...

  3. PHP错误类型及屏蔽方法

    1. 注意(Notices)这些都是比较小而且不严重的错误,比如去访问一个未被定义的变量.通常,这类的错误是不提示给用户的,但有时这些错误会影响到运行的结果. 2. 警告(Warnings)这就是稍微 ...

  4. SPFA 小优化*2

    /* bzoj 2763 SPFA小优化 循环队列+SLF 顺面改掉自己之前手打qeueu的坏毛病*/ #include<iostream> #include<cstring> ...

  5. Weex 初始

    1.一旦数据和模板绑定,数据的变化会立即体现在前台的变化 <template> <container> <text style="font-size: {{si ...

  6. angularJS function

    angular.bootstrap 启动Angular angular.element 相当于轻量的JQuery 使用方法: angular.element('#qq'); angular.eleme ...

  7. br与p标签区别

    首先,相同之处是br和p都是有换行的属性及意思其次,区别<br />是只需一个单独使用,而<p>和</p>是一对使用再次,br标签是小换行提行,p标签是大换行(分段 ...

  8. The performance between the 'normal' operation and the 'shift' operation.

    First, I gonna post my test result with some code: //test the peformance of the <normal operation ...

  9. openwrt advanced configuration

    openwrt高级配置(汗 照着标题就翻译过来了) openwrt Kamikaze 8.09的一般配置文件都在目录 /etc/config 下面,可以使用脚本来调用参数和设置参数. 比如 sbin/ ...

  10. 解决ubuntu下的文本编辑器gedit的乱码问题

    缺省配置下,用 Ubuntu 的文本编辑器(Gedit)打开GB18030(繁体中文用户请将这里的出现的GB18030替换成BIG5或BIG5-HKSCS)类型的中文编码文本文件时,将会出现乱码. 出 ...