/*
* 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. Html之img标签

    我发现了为什么我不会开发,或者不愿意,我感觉是因为我不会前端,自认为写出来完美的后台显示不好也没人用,为了解决这一问题,笔者新增html栏目,和大家一起交流分享. 一.img必须有src和alt属性 ...

  2. 关于JDNI、JMX

    http://www.cnblogs.com/itech/archive/2010/09/16/1827999.html http://javacrazyer.iteye.com/blog/75948 ...

  3. 开启CURL扩展,让服务器支持PHP curl函数(远程采集)

    关于开启Curl的方法模板天下小编在此给大家简单说一下 curl().file_get_contents().snoopy.class.php这三个远程页面抓取或采集中用到的工具,默迹还是侵向于用sn ...

  4. codevs 版刷计划(1000-1099)

    Diamond咋都是模板题... 开个坑刷codevs的Master题.巩固一下姿势. 目前AC的题目:1001,1021,1022, 1001.舒适的路线(并查集) 求出无向图s到t路径上的min( ...

  5. 【无聊放个模板系列】HDU 1358 KMP

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  6. RxJava开发精要5 – Observables变换

    原文出自<RxJava Essentials> 原文作者 : Ivan Morgillo 译文出自 : 开发技术前线 www.devtf.cn 转载声明: 本译文已授权开发者头条享有独家转 ...

  7. 【Quick 3.3】资源脚本加密及热更新(二)资源加密

    [Quick 3.3]资源脚本加密及热更新(二)资源加密 注:本文基于Quick-cocos2dx-3.3版本编写 一.介绍 在前一篇文章中介绍了代码加密,加密方式是XXTEA.对于资源文件来说,同样 ...

  8. 【HDOJ】1076 An Easy Task

    水题,如题. #include <stdio.h> #define chk(Y) (Y%4==0 && Y%100!=0) || Y%400==0 int main() { ...

  9. BZOJ_1614_ [Usaco2007_Jan]_Telephone_Lines_架设电话线_(二分+最短路_Dijkstra/Spfa)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1614 分析 类似POJ_3662_Telephone_Lines_(二分+最短路) Dijks ...

  10. [swustoj 764] 校门外的树 Plus Plus

    校门外的树 Plus Plus(0764) 问题描述 西南某科技大学的校门外长度为 L 的公路上有一排树,每两棵相邻的树之间的间隔都是 1 米.我们可以把马路看成一个数轴,马路的一端在数轴 1 的位置 ...