(贪心5.1.1)POJ 1230 Pass-Muraille
/*
* POJ_1230.cpp
*
* Created on: 2013年10月9日
* Author: Administrator
*/ #include <iostream>
#include <cstdio> using namespace std; int map[105][105]; int main() {
int t, n, k, x, y, x1, y1, max_x, max_y, sum_s; scanf("%d", &t);
while (t--) {
max_x = 0;
max_y = 0;
sum_s = 0;
memset(map, 0, sizeof(map)); scanf("%d%d", &n, &k);
int i;
for (i = 1; i <= n; ++i) {
scanf("%d%d%d%d", &x, &y, &x1, &y1); if (x > max_x) {
max_x = x;
} if (x1 > max_x) {
max_x = x1;
} if (y > max_y) {
max_y = y;
} int j;
if (x < x1) {
for (j = x; j <= x1; ++j) {
map[j][y] = i;
}
} else {
for (j = x1; j <= x; ++j) {
map[j][y] = i;
}
}
} for (i = 0; i <= max_x; ++i) {
int temp = 0;
int j;
for (j = 0; j <= max_y; ++j) {
if (map[i][j] > 0) {
temp++;
}
} int offset = temp - k;
if (offset > 0) {
sum_s += offset; while (offset--) {
int max_s = 0;
int max_bh = 0;
int k;
for (k = 0; k <= max_y; ++k) {
if (map[i][k] > 0) {
int z;
int temp_s = 0;
for (z = i + 1; z <= max_x; ++z) {
if (map[z][k] == map[i][k]) {
temp_s++;
} else {
break;
}
} if (max_s < temp_s) {
max_s = temp_s;
max_bh = k;
}
}
} int a;
for (a = i; a <= i + max_s; ++a) {
map[a][max_bh] = 0;
}
}
}
} printf("%d\n", sum_s);
} return 0;
}
(贪心5.1.1)POJ 1230 Pass-Muraille的更多相关文章
- zoj 1375||poj 1230(贪心)
Pass-Muraille Time Limit: 2 Seconds Memory Limit: 65536 KB In modern day magic shows, passing t ...
- POJ 1230 Pass-Muraille#贪心+vector迭代器用法
(- ̄▽ ̄)-* (注意下面代码中关于iterator的用法,此代码借鉴某大牛) #include<iostream> #include<cstdio> #include< ...
- (并查集 贪心思想)Supermarket -- POJ --1456
链接: http://poj.org/problem?id=1456 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82830#probl ...
- 【贪心】Communication System POJ 1018
题目链接:http://poj.org/problem?id=1018 题目大意:有n种通讯设备,每种有mi个制造商,bi.pi分别是带宽和价格.在每种设备中选一个制造商让最小带宽B与总价格P的比值B ...
- 【贪心】Moving Tables POJ 1083
题目链接:http://poj.org/problem?id=1083 题目大意:走廊上的房间如下图设置,现在有n个移动桌子的任务,把桌子从xi移动到yi(整个过程中会占用xi到yi房间之间的走廊), ...
- 贪心-Saruman‘s Army POJ - 3069
万恶之源 目录 题意 思路 贪心的原则是什么呢? 错解 正解 代码实现 书上的代码 我的代码 比较一下 问题 题意 给定若干个点的坐标,与范围R.每个点可以选择是否标记,标记后这个点的左右范围R内的所 ...
- (贪心5.1.2)POJ 2287 Tian Ji -- The Horse Racing
/* * POJ_2287.cpp * * Created on: 2013年10月9日 * Author: Administrator */ #include <iostream> #i ...
- 贪心算法——Fence Repair(POJ 3253)
题目描述 农夫约翰为了修理栅栏,要将一块很长的木板切割成N块.准备切成的木板长度为L1,L2,L3--LN,未切割前木板的长度恰好为切割后木板长度的总和.每次切断木板时,需要的开销为这块木板的长度.请 ...
- POJ 1230 Pass-Muraille
#include<iostream> #include<cstring> using namespace std; ; //(x,y) (x1,y1)墙的两个端点,所有墙最大列 ...
随机推荐
- Jfinal 入门
Jfinal 入门 IDE----->IDEA 新建项目 新建web项目 添加maven特性 方便导入jar包,不用一个个导入了 配置pom.xml <dependencies> & ...
- 事件——《JS高级程序设计》
一. 事件流 1. 事件流描述的是从页面中接收事件的顺序 2. 事件冒泡(event bubble):事件从开始时由最具体的元素(就是嵌套最深的那个节点)开始,逐级向上传播到较为不具体的节点(就是Do ...
- Linux(CentOS)常用命令
http://fedoranews.org/alex/tutorial/rpm/3.shtml rpm.org rpm -qa|grep mysql 查询已安装的含有mysql的包. mv 移动文件. ...
- Android开发UI之常用控件的使用
1.日期选择控件 DatePickerDialog 代码: btnChooseDate=(Button) findViewById(R.id.btnChooseDate); btnChooseDate ...
- centos中忘记root密码问题
centos中root密码问题 几次在虚拟机中安装cenos,都没有提示输入root密码,具体操作如下: 1.在启动的时候,进入启动界面后,按除了Enter键之外的任意键,即可进入该界面.然后 按 ...
- MySQL 线上配置文件
[client] port = 3306 socket = /tmp/mysql.sock default-character-set = utf8 [mysq ...
- [HUST 1017] Exact cover
Exact cover Time Limit: 15s Memory Limit: 128MB Special Judge Submissions: 6012 Solved: 3185 DESCRIP ...
- ASP.NET操作Word的IIS权限配置
ASP.NET账号在默认情况下是没有权限操作Microsoft Office对象的,如果不进行权限的配置,代码会抛出类似以下的异常: 检索 COM 类工厂中 CLSID 为 {00024500-000 ...
- 使用Arcglobe 10与3dmax建立三维城市
转自:http://www.cnblogs.com/jinlun/p/3380307.html 随着国家大力推进数字城市的建设,三维城市的建设也是势在必行的.与传统二维地图相比,三维城市在立体层次.视 ...
- 使用PowerDesigner建立数据库模型
转自:http://www.cnblogs.com/tonyepaper/archive/2008/02/12/1067260.html 1. 打开PowerDesigner,点击File ...