Second Large Rectangle 题目传送门 解题思路 先求出每个点上的高,再利用单调栈分别求出每个点左右两边第一个高小于自己的位置,从而而得出最后一个大于等于自己的位置,进而求出自己的位置的高为高,这个点所在的边为底的最大矩形.这些求出的矩形中的最大值即为可求出的最大矩形.而次大值可能是这些矩形之一,也可能是这些矩形的高减1或者宽减1得到的矩形.所以把这些全都记录下来,第二大的即为答案.由于这样求出的矩形会有重复,所以记录一下坐标来去重. 代码如下 #include <bits/s…
把以前的题补补,用悬线求面积第二大的子矩形.我们先求出最大子矩阵的面积,并记录其行三个方向上的悬线长度.然后排除这个矩形,记得还得特判少一行或者少一列的情况 #include <bits/stdc++.h> using namespace std; ; int n; int mat[maxn][maxn],Left[maxn][maxn],Right[maxn][maxn],up[maxn][maxn]; int main() { int T; T=; while(T--) { int m,n…
Eddy Walker 题目传送门 解题思路 因为走过所有的点就会停下来,又因为是从0出发的,所以当n>1时,在0停下来的概率为0,其他的为1/(n-1); 代码如下 #include <bits/stdc++.h> #define INF 0x3f3f3f3f using namespace std; typedef long long ll; inline int read(){ int res = 0, w = 0; char ch = 0; while(!isdigit(ch))…
链接:https://ac.nowcoder.com/acm/contest/881/E 来源:牛客网 ABBA 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 Bobo has a string of length 2(n + m) which consists of characters A and B. The string also has a fascinating prop…
链接:https://www.nowcoder.com/acm/contest/140/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 White Cloud is exercising in the playground. White Cloud can walk 1 meters or run k meters per second. Since White Clou…
链接:https://www.nowcoder.com/acm/contest/140/A来源:牛客网 题目描述 White Cloud is exercising in the playground. White Cloud can walk 1 meters or run k meters per second. Since White Cloud is tired,it can't run for two or more continuous seconds. White Cloud wi…
链接:https://www.nowcoder.com/acm/contest/140/G White Cloud placed n containers in sequence on a axes. The i-th container is located at x[i] and there are a[i] number of products in it. White Rabbit wants to buy some products. The products which are re…