给出一系列的1*h的矩形,求矩形的最大面积. 如图: 题解链接:点我 #include <iostream> #include <cstdio> using namespace std; ; struct Elem { int height; int count; }; Elem stack[N]; int top; int main() { int height, n; long long ans, tot, tmp; while (scanf("%d", &…
题目链接:http://poj.org/problem?id=2796 单调栈可以O(n)得到以每个位置为最小值,向左右最多扩展到哪里. #include<cstdio> #include<algorithm> #include<stack> using namespace std; ; int a[maxn]; int l[maxn]; int r[maxn]; long long pre[maxn]; stack< pair<int,int> &g…
1619 - Feel Good Time limit: 3.000 seconds Bill is developing a new mathematical theory for human emotions. His recent investigations are dedi- cated to studying how good or bad days in uent people's memories about some period of life. A new idea B…
和poj2082差不多,加了一个宽度的条件 #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<iostream> using namespace std; ; pair<int,int> ele[MAXN]; int main(){ int height, n; int w; int i,j,k,h; int ans, tot…
http://poj.org/problem?id=2559 Largest Rectangle in a Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12297 Accepted: 3974 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base lin…
[POJ 2559]Largest Rectangle in a Histogram 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 s…
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…
传送门 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…
Largest Rectangle in a Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15831 Accepted: 5121 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
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…
Largest Rectangle in a Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26549 Accepted: 8581 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
http://poj.org/problem?id=3415 Common Substrings Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5805 Accepted: 1911 Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two strings A, B an…
http://poj.org/problem?id=3250 Bad Hair Day Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11473 Accepted: 3871 Description Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious abou…
Feel Good Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18449 Accepted: 5125 Case Time Limit: 1000MS Special Judge Description Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated…
POJ 3494 Largest Submatrix of All 1’s Description Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements. Input The input contains multiple test cases. Each tes…
题目:http://poj.org/problem?id=3415 先用后缀数组处理出 ht[i]: 用单调栈维护当前位置 ht[i] 对之前的 ht[j] 取 min 的结果,也就是当前的后缀与之前后缀的LCP,其中长度 >= K 的加到答案: 因为单调栈中是一段一段阶梯状的,只存了一段端点的位置,所以再记录一个 cnt 表示这一段的长度,算贡献时乘上 cnt: 因为是两个串之间,所以先统计 B 在 A 排名前的答案,再重复一遍统计 A 在 B 排名前的答案: 但是 ht[i] 是 sa[i]…