/*
* 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. 我的PHP之旅--认识数据库及数据库操作

    数据库基本知识 什么是数据库服务器:安装了数据库软件的电脑,就是数据库服务器,同理安装了Apache软件的电脑就是www服务器. 什么是DBMS:database management system( ...

  2. c语言通过89C51驱动1602液晶显示(入门级别)

    工具proteus,keil 步骤: 1.画好电路图 2.在指令模式下,设置好显示模式以及光标位置 3.在写数据模式下,向1602写入显示字符(1602只能显示数字和字符) 电路图 #include ...

  3. 换一换js

    (function(){ var tit = $("#changes"), con = $("#wday>ul"), page = con.length, ...

  4. unity 与 android 协调工作 注意事项

    原地址:http://blog.csdn.net/u012085988/article/details/17436191 1.unity调android函数 AndroidJavaClass jc = ...

  5. asp.net将sql语句封装在类库中

    将sql语句封装在cs中,通过类库的引用使用他的select.update.insert 源代码(cs): using System; using System.Collections.Generic ...

  6. 酷盘kanbox获得B轮2000万美元融资

    和阿里近期收购以穷游.虾米为代表的一批小网站相似,酷盘也属于个人用户数量级别庞大,但商业模式并不明晰的企业.目前阿里巴巴集团旗下的阿里云公司拥有自己的云存储业务,其本身既有面向个人用户的产品,也有面向 ...

  7. Attribute的一个列子

    其实在博客中也写过这个东西,也介绍过它的原理,原理很简单,就是在运行的时候通过反射拦截获取一些信息,但是我在写程序的时候几乎没用过,可能是自己接触的还不够多,也许是因为自己接触的功能不算复杂往往几句代 ...

  8. 【HDOJ】1061 Rightmost Digit

    这道题目可以手工打表,也可以机器打表,千万不能暴力解,会TLE. #include <stdio.h> #define MAXNUM 1000000001 ][]; int main() ...

  9. 我的第一个Spring程序

    1.程序结构 2.各个文件 ByeService.java package com.service; public class ByeService { private String name; pu ...

  10. URAL1036. Lucky Tickets

    链接 dp[i][j] += dp[i-1][j-g];背包吧 数据太大了 还是JAVA好用 import java.io.*; import java.math.*; import java.tex ...