/*
* 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的更多相关文章

  1. zoj 1375||poj 1230(贪心)

    Pass-Muraille Time Limit: 2 Seconds      Memory Limit: 65536 KB In modern day magic shows, passing t ...

  2. POJ 1230 Pass-Muraille#贪心+vector迭代器用法

    (- ̄▽ ̄)-* (注意下面代码中关于iterator的用法,此代码借鉴某大牛) #include<iostream> #include<cstdio> #include< ...

  3. (并查集 贪心思想)Supermarket -- POJ --1456

    链接: http://poj.org/problem?id=1456 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82830#probl ...

  4. 【贪心】Communication System POJ 1018

    题目链接:http://poj.org/problem?id=1018 题目大意:有n种通讯设备,每种有mi个制造商,bi.pi分别是带宽和价格.在每种设备中选一个制造商让最小带宽B与总价格P的比值B ...

  5. 【贪心】Moving Tables POJ 1083

    题目链接:http://poj.org/problem?id=1083 题目大意:走廊上的房间如下图设置,现在有n个移动桌子的任务,把桌子从xi移动到yi(整个过程中会占用xi到yi房间之间的走廊), ...

  6. 贪心-Saruman‘s Army POJ - 3069

    万恶之源 目录 题意 思路 贪心的原则是什么呢? 错解 正解 代码实现 书上的代码 我的代码 比较一下 问题 题意 给定若干个点的坐标,与范围R.每个点可以选择是否标记,标记后这个点的左右范围R内的所 ...

  7. (贪心5.1.2)POJ 2287 Tian Ji -- The Horse Racing

    /* * POJ_2287.cpp * * Created on: 2013年10月9日 * Author: Administrator */ #include <iostream> #i ...

  8. 贪心算法——Fence Repair(POJ 3253)

    题目描述 农夫约翰为了修理栅栏,要将一块很长的木板切割成N块.准备切成的木板长度为L1,L2,L3--LN,未切割前木板的长度恰好为切割后木板长度的总和.每次切断木板时,需要的开销为这块木板的长度.请 ...

  9. POJ 1230 Pass-Muraille

    #include<iostream> #include<cstring> using namespace std; ; //(x,y) (x1,y1)墙的两个端点,所有墙最大列 ...

随机推荐

  1. python中数据的保存

    1.将list中的数据写入到excel文件中 利用python包numpy(实现方式应该有许多种,这里只是记录成功实现的一种)中的savetxt 局限性:要保存的list可以为[1,2,3,4,5]这 ...

  2. Spring中argNames的含义

    最近学习Spring,一直不太明白Srping的切面编程中的的argNames的含义,经过学习研究后,终于明白,分享一下 先看一个例子: 需要监控的类: package bean; public cl ...

  3. xss攻击入门

    xss表示Cross Site Scripting(跨站脚本攻击),它与SQL注入攻击类似,SQL注入攻击中以SQL语句作为用户输入,从而达到查询/修改/删除数据的目的,而在xss攻击中,通过插入恶意 ...

  4. 从Clarifai的估值聊聊深度学习

    从Clarifai的估值聊聊深度学习 [转载请注明出处] 前几天和 Ayden @叶瀚中 聊天时,提到了 www.clarifai.com 这家公司. 此前,我已经从各方消息中听说过创始人Matt Z ...

  5. android 小米手机连接到电脑adb无法识别 解决方案

    下载并安装小米手机助手 它会自动帮你安装驱动程序 安装成功后重启一下adb服务 应该就可以了

  6. 一个用于清除loadrunner产生log文件的批处理

    @echo off set work_path="%~dp0" for /R %%s in (*.txt,*.log) do ( del /f "%%s" ) ...

  7. eCos中断模型

    http://blog.csdn.net/chychc/article/details/8313458 http://www.cnblogs.com/RandyQ/archive/2013/04/14 ...

  8. ANDROID_MARS学习笔记_S02_008_ANIMATION第二种使用方式:xml

    一.简介 二.代码1.res\anim下的xml(1)alpha.xml.xml <?xml version="1.0" encoding="utf-8" ...

  9. 关于百度地图API的地图坐标转换问题

    原文:关于百度地图API的地图坐标转换问题 我在之前的文章利用html5获取经纬度并且在百度地图中显示位置中使用了百度地图的API来显示html5获取的地理位置,在文中我说过这样的话,我说百度地图的准 ...

  10. Tomcat 6.0下配置HTTPS

    最近项目需要使用到https,所以回顾整理了一下,其实在tomcat的文档中已经有了详细描述,我们启动Tomcat后,可以在docs文档中找到 地址如下:http://localhost:8080/d ...