Rectangle(csu)】的更多相关文章

Description Now ,there are some rectangles. The area of these rectangles is 1* x or 2 * x ,and now you need find a big enough rectangle( 2 * m) so that you can put all rectangles into it(these rectangles can't rotate). please calculate the minimum m…
Rectangle Problem's Link:   http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1547 Mean: 给你一些宽为1或2 的木板,让你放在一个宽为二的盒子里面,问你这个盒子最短有多长. analyse: 简单dp,一开始想错了. Time complexity: O(n) Source code:  // Memory Time // 1347K 0MS // by : crazyacking // 2015-03-29-…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1547 Description Now ,there are some rectangles. The area of these rectangles is 1* x or 2 * x ,and now you need find a big enough rectangle( 2 * m) so that you can put all rectangles into it(th…
1547: Rectangle Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Submitted: 1198     Solved: 347 Description Now ,there are some rectangles. The area of these rectangles is 1* x or 2 * x ,and now you need find a big enough rec…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1547 题解: 关键是怎么处理长度为1的长方形.当长度为1的长方形的个数cnt>=2时,怎么把这些长方形分成两组,使得这两组的高度差最小,即最接近H/2.一开始用贪心做,结果wa了.因为贪心出来的不一定是最优,于是就想到了用dp.dp出H/2最大能够容纳的高度.然后再取 H-dp[H/2]. 代码如下: #include <iostream> #include <cst…
http://www.51nod.com/onlineJudge/questionCode.html#problemId=1007&noticeId=15020 求出n个数的和sum,然后用sum/2作为背包容量,让n个数去放,求出一个最大价值,那么这就是其中一组的和,另外一组的和就是sum-dp[sum/2]; 注意这里的体积和价值都是a[i]; #include <iostream> #include <cstdio> #include <cmath> #i…
Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region. Each rectangle is represented as a bottom-left point and a top-right point. For example, a unit square is represented as [1,1,2,2…
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k. Example: Given matrix = [ [1, 0, 1], [0, -2, 3] ] k = 2 The answer is 2. Because the sum of rectangle [[0, 1], […
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontally and vertically. Given the location (x, y) of one of the…
Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Assume that the total area is never beyond the maximum possible value of int. Cre…
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. 此题是之前那道的Largest Rectangle in Histogram 直方图中最大的矩形 的扩展,这道题的二维矩阵每一层向上都可以看做一个直方图,输入矩阵有多少行,就可以形成多少个直方图,对每个直方图都调用Largest Rectangle in Hist…
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The largest…
很不好想的一道题,参考:http://blog.csdn.net/doc_sgl/article/details/11832965 分为两步:把原矩阵转为直方图,再用largest rectangle求解:http://www.cnblogs.com/573177885qq/p/5537334.html int largestRectangleArea(vector<int>& heights) { stack<int> s; heights.push_back(); ;…
85. Maximal Rectangle Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 0 0 1 0 Return 6.…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19782   Accepted: 6393 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
题目: Largest Rectangle in Histogram Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given h…
http://blog.csdn.net/abcbc/article/details/8943485 具体的题目描述为: Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width…
 SCU 4440 Rectangle Time Limit:0MS     Memory Limit:0KB     64bit IO Format:%lld & %llu  Practice Description Rectangle frog has a piece of paper divided into nn rows and mm columns. Today, she would like to draw a rectangle whose perimeter is not gr…
Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rectang…
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The largest…
题目如下:(https://leetcode.com/problems/largest-rectangle-in-histogram/) Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.          Above is a hist…
首先上题目 Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. For example,Given height = [2,1,5,6,2,3],return 10. 题目的大意即给出一个柱状图的歌数据,求柱状图内所包含的最大矩形. 这道…
一问题描述 Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The la…
Largest Rectangle in a Histogram Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 16   Accepted Submission(s) : 6 Problem Description A histogram is a polygon composed of a sequence of rectangles…
传送门:csu 1812: 三角形和矩形 思路:首先,求出三角形的在矩形区域的顶点,矩形在三角形区域的顶点.然后求出所有的交点.这些点构成一个凸包,求凸包面积就OK了. /************************************************************** Problem: User: youmi Language: C++ Result: Accepted Time: Memory: ***********************************…
之前切了道求解最大正方形的题,题解猛戳 这里.这道题 Maximal Rectangle 题意与之类似,但是解法完全不一样. 先来看这道题 Largest Rectangle in Histogram,如果暴力求解,可以枚举每个点为最小值,向两边扩展,复杂度 O(n^2).我们可以维护一个栈,从而将复杂度降低到 O(n),这个栈的思维非常巧妙,参考了 discuss,我是完全想不出来(或者说忘记了).具体代码可以猛戳 这里. 2016-08-07 补:stack 数组维护的是一个单调递增的数组,…
传送门 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rec…
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这样的话点到圆弧的最短距离就是点到圆心的距离减去半径然后再取绝对值就可以了,第二种情况是那个点跟圆心的连线不在那段扇形的圆弧范围内,这样的话,最短的距离就是到这段圆弧的端点的最小值. 接下来的第一步就是求圆心的坐标跟圆的半径,只要求出圆心坐标半径就好说了,求圆心坐标我用的方法是: 设圆心坐标是(a,b…
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1120 解题报告:dp,用一个串去更新另一个串,递推方程是: if(b[i] > a[j]) m = max(m,dp[j]); else if(b[i] == a[j]) dp[j] = m + 1; #include<cstdio> #include<cstring> #include<iostream> #include<algorithm&g…
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1116 解题报告:一个国家有n个城市,有m条路可以修,修每条路要一定的金币,现在这个国家只有K个金币,每个城市有一些人,要你求怎么修路使得总的费用在K的范围内,同时使得跟首都连接的城市的人口(包括首都的人口)要最多,问最多的人口是多少. 枚举连接哪些城市,然后分别构造最小生成树. #include<cstdio> #include<cstring> #include<…