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 ...
随机推荐
- SQL Server占用内存的认识
SQL Server占用的内存主要由三部分组成:数据缓存(Data Buffer).执行缓存(Procedure Cache).以及SQL Server引擎程序.SQL Server引擎程序所占用缓存 ...
- gzip
gzip -c 将输出写到标准输出上,并保留原文本 gzip * : 把当前目录中的每个文件压缩成.gz文件 [root@NB gzip]# ls mysql-bin. mysql-bin..tar ...
- htop 源码安装
htop-1.0.2.tar.gz http://pan.baidu.com/s/1c1RbdIg tar -xvf htop-1.0.2.tar.gz cd htop-1.0.2 ./config ...
- Delphi中线程类TThread实现多线程编程1---构造、析构……
参考:http://www.cnblogs.com/rogee/archive/2010/09/20/1832053.html Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大 ...
- Sexagenary Cycle(天干地支法表示农历年份)
Sexagenary Cycle Time Limit: 2 Seconds Memory Limit: 65536 KB 题目链接:zoj 4669 The Chinese sexagen ...
- eclipse基础及开发插件
Eclipse:http://www.eclipse.org/downloads/ Compare Package:http://www.eclipse.org/downloads/packages/ ...
- 【leetcode】Remove Duplicates from Sorted Array
题目描述: Given a sorted array, remove the duplicates in place such that each element appear only once a ...
- windows下R语言在终端的运行
在windows下可以有多种方式来运行R,R导论的这些章节给出一些详细的指导. 通常在环境变量离包含R的安装目录类似于R\R-3.1.2\bin\x64的情况下,就可以在CMD下运行R程序了 注意我这 ...
- 虚拟机下玩DXF
DXF检测虚拟机好象已经很长时间了,记得当时也是在网上找的教程,今天无聊又检测了一下,发现目前依然有效.用记事本打开 虚拟机启动文件 xxxx.vmx 在最后添加如下两行代码monitor_contr ...
- SQL详解(下)
约束 *约束是添加在列上的,用来约束列的! 1. 主键约束(唯一标识) 特点:非空,唯一,被引用 创建表时指定主键的两种方式,分别为: CREATE TABLE stu( sid ...