把以前的题补补,用悬线求面积第二大的子矩形.我们先求出最大子矩阵的面积,并记录其行三个方向上的悬线长度.然后排除这个矩形,记得还得特判少一行或者少一列的情况 #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…
链接:https://ac.nowcoder.com/acm/contest/884/K来源:牛客网 题目描述 300iq loves numbers who are multiple of 300. One day he got a string consisted of numbers. He wants to know how many substrings in the string are multiples of 300 when considered as decimal inte…
链接:https://www.nowcoder.com/acm/contest/147/E 来源:牛客网 题目描述 Niuniu likes to play OSU! We simplify the game OSU to the following problem. Given n and m, there are n clicks. Each click may success or fail. For a continuous success sequence with length X,…
链接:https://www.nowcoder.com/acm/contest/142/A 来源:牛客网 题目描述 A ternary , , or . Chiaki has a ternary in the string, and finally the first character will disappear. For example, ``'' after another second. Chiaki would like to know the number of seconds n…
链接: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…
Second Large Rectangle 题目传送门 解题思路 先求出每个点上的高,再利用单调栈分别求出每个点左右两边第一个高小于自己的位置,从而而得出最后一个大于等于自己的位置,进而求出自己的位置的高为高,这个点所在的边为底的最大矩形.这些求出的矩形中的最大值即为可求出的最大矩形.而次大值可能是这些矩形之一,也可能是这些矩形的高减1或者宽减1得到的矩形.所以把这些全都记录下来,第二大的即为答案.由于这样求出的矩形会有重复,所以记录一下坐标来去重. 代码如下 #include <bits/s…
题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m1≤l≤r≤m where RMQ(w,l,r) denotes the index of the minimum element among wl,wl+1,-,wr. Since the array contains distinct el…
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))…