codeforces Round #252 (Div. 2) C - Valera and Tubes
贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完
由于数据比较小,可以先打表
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std; typedef pair<int,int> Point; int main(){
int n, m, k, flag = -;
cin >> n >> m >>k;
vector<Point> table;
for(int i = ; i < n ; ++i){
flag*=-;
for(int j = ; j < m; ++ j){
table.push_back(Point(i,flag> ? j : (m--j)));
}
}
for(int i = ; i <*(k -); i+=){
cout<<<<" "<<table[i].first+<<" "<<table[i].second+<<" "<<table[i+].first+<<" "<<table[i+].second+<<endl;
}
cout<<m*n-*(k-);
for(int i = *(k-); i < m*n; ++ i ){
cout<<" "<<table[i].first+<<" "<<table[i].second+;
}
cout<<endl;
}
关于额外的信息, |xi - xi + 1| + |yi - yi + 1| = 1,其实就是一个点的四连通区域,即上下左右4个点
codeforces Round #252 (Div. 2) C - Valera and Tubes的更多相关文章
- Codeforces Round #252 (Div. 2) B. Valera and Fruits(模拟)
B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #252 (Div. 2) B. Valera and Fruits
#include <iostream> #include <vector> #include <algorithm> #include <map> us ...
- Codeforces Round #252 (Div. 2) A - Valera and Antique Items
水题 #include <iostream> #include <set> #include <vector> #include <algorithm> ...
- Codeforces Round #252 (Div. 2) 441B. Valera and Fruits
英语不好就是坑啊.这道题把我坑残了啊.5次WA一次被HACK.第二题得分就比第一题高10分啊. 以后一定要加强英语的学习,要不然就跪了. 题意:有一个果园里有非常多树,上面有非常多果实,为了不然成熟的 ...
- Codeforces Round 252 (Div. 2)
layout: post title: Codeforces Round 252 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- [Codeforces Round #237 (Div. 2)] A. Valera and X
A. Valera and X time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #216 (Div. 2) D. Valera and Fools
题目链接:http://codeforces.com/contest/369/problem/D 注意题意:所有fools都向编号最小的fool开枪:但每个fool都不会笨到想自己开枪,所以编号最小的 ...
- Codeforces Round #252 (Div. 2) D
http://codeforces.com/problemset/problem/441/D 置换群的基本问题,一个轮换内交换成正常顺序需要k-1次,k为轮换内元素个数 两个轮换之间交换元素,可以把两 ...
- Codeforces Round #216 (Div. 2) B. Valera and Contest
#include <iostream> #include <algorithm> #include <vector> using namespace std; in ...
随机推荐
- Spring.Net的AOP的通知
一.拦截环绕通知(around advice):Spring.NET中最基本的通知类型是拦截环绕通知(interception around advice),即方法拦截器.拦截环绕通知继承IMetho ...
- Delphi中的异常处理
转载:http://www.cnblogs.com/doit8791/archive/2012/05/08/2489471.html 以前写Delphi程序一直不注意异常处理,对其异常处理的机制总是一 ...
- <转>删除文件夹下所有的.svn文件
当使用了svn版本控制系统后每个目录下都会有一个.svn目录存在,开发完当交付产品或者上传到服务器时一般要把这些目录删除,这里总结了一下在linux和win下的办法. 一.在linux下 删除这些目录 ...
- MS SQL数据批量备份还原(适用于MS SQL 2005+) 分类: SQL Server 数据库 2015-03-10 14:32 103人阅读 评论(0) 收藏
我们知道通过Sql代理,可以实现数据库的定时备份功能:当数据库里的数据库很多时,备份一个数据库需要建立对应的定时作业,相对来说比较麻烦: 还好,微软自带的osql工具,比较实用,通过在命令行里里输入命 ...
- 数据结构之图 Part1
Part 1 预计使用7天的时间来过掉图相关的数据结构.第一天主要是一天图的基本概念,熟练掌握定义是一切交流和沟通的基础. 1定义 1.1图 有穷非空顶点,外加边. G(V,E) Graph Vert ...
- PowerDesigner连接Oracle数据库生成数据模型【本地连接方式】
步骤1:选择数据库 步骤2:选择要连接的数据库的版本 步骤3:新建数据库连接 步骤4:提供3种连接数据库方式(在此选择第3种),并且点击配置按钮,进行下一步 步骤5:点击此按钮,填 ...
- ereg/eregi报错处理办法
ereg()函数和eregi()函数用法相同,不同之处在与ereg()区分大小写,eregi()不区分大小写 在php5.3以上的版本将不再支持eregi()和ereg()函数 处理办法: 正则函数处 ...
- Java关键字native、volatile、transient
native native是方法修饰符.Native方法是由另外一种语言(如c/c++,FORTRAN,汇编)实现的本地方法.一般用于JNI中. native关键字说明其修饰的方法是一个原生态方法,方 ...
- Android在listview添加checkbox实现单选多选操作问题(转)
转自:http://yangshen998.iteye.com/blog/1310183 在Android某些开发需求当中,有时候需要在listveiw中加入checkbox实现单选,多选操作.表面上 ...
- vmware虚拟机检测
jpg改rar