摘要:
如上图所示,我们看这代码分析首先,单调栈必须保证单调对吧,所以说我们将大于栈顶元素的元素入栈,直到遇到一个小于栈顶元素的数,然后因为是单调栈,所以我们想让它入栈,就必须删除栈中比他大的元素,但是又要不影响结果,所以每个栈顶元素出栈是都要计算它与前面出栈元素组成的最大矩形,直到在栈中找到一个比待入栈元 阅读全文
摘要:
如上图所示,我们看这代码分析 首先,单调栈必须保证单调对吧,所以说我们将大于栈顶元素的元素入栈,直到遇到一个小于栈顶元素的数,然后因为是单调栈,所以我们想让它入栈,就必须删除栈中比他大的元素,但是又要不影响结果,所以每个栈顶元素出栈是都要计算它与前面出... 阅读全文
摘要:
用两个栈来模拟光标的移动,sum来维护A栈的前缀和,f用来维护最大值。 1 #include <iostream> 2 #include <algorithm> 3 #include <stack> 4 using namespace std; 5 stack<int> A, B; 6 conste 阅读全文
摘要:
用两个栈来模拟光标的移动,sum来维护A栈的前缀和,f用来维护最大值。 1 #include 2 #include 3 #include 4 using namespace std; 5 stack A, B; 6 const... 阅读全文
摘要:
1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 const int N = 1e5 + 10, M = 1e4 + 10; 7 8 int m, n; 9 string p, t; 10 11 int ne 阅读全文
摘要:
1 #include 2 #include 3 4 using namespace std; 5 6 const int N = 1e5 + 10, M = 1e4 + 10; 7 8 int m, n; 9 strin... 阅读全文