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 ...
随机推荐
- Struts2(八)访问Servlet API
一.Struts2中的Servlet API 1.1.struts2的Action实现了MVC中C层的作用 针对请求用户显示不同的信息 登录后段保存用户信息 ----session 保存当前在线人数等 ...
- HTML一(简介)
什么是 HTML? HTML 是用来描述网页的一种语言. HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML 不是一种编程语言,而是一种标记语言 (ma ...
- KeyBoardUtils.java——android键盘工具类
package com.xdsjs.save.utils; import android.content.Context; import android.view.inputmethod.InputM ...
- maven的下载以及安装
1.下载Maven 打开链接:https://maven.apache.org/download.cgi 下载好之后解压到一个盘,我的是解压到F:\Maven\apache-maven-3.5.3-b ...
- How to use OpenChatter in my addon
from:https://doc.openerp.com/trunk/mail/mail_openchatter_howto/ A small my_task model will be used a ...
- How to hide the create button dynamical tree view in openerp ?
<tree create="false" edit="false" > <tree attrs="{'create':[(" ...
- OpenERP7.0安装后提示“not supported" ,如何去掉此提示
转自:http://blog.csdn.net/vnsoft/article/details/17581831 下载了新版本的OpenERP7.0安装测试,发现在登录后会提示如图的内容. 经过测试发现 ...
- 〖Android〗/system/etc/audio_policy.conf
原文件注释说明: # audio hardware module section: contains descriptors for all audio hw modules present on t ...
- 【TP3.2】:日志记录和查看
1.TP3.2手册日志类链接:http://document.thinkphp.cn/manual_3_2.html#log 2.日志默认路径:/Application/Runtime/Logs 3. ...
- HDUOJ-------1753大明A+B(大数之小数加法)
大明A+B Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...