2 条题解
-
1
思路:
这道题就是在直方图中的矩形里再多一个枚举 行就行了,下面是代码
AC代码:
#include<iostream> #include<stack> #include<string.h> #define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define int long long using namespace std; stack<int> st; int h[1005][1005],n,to,l[1005],r[1005],res,m; int get(int index){ int ans; while(!st.empty()) st.pop(); h[0][index]=-1; st.push(0); for(int i=1;i<=n;i++){ while(!st.empty()&&h[i][index]<=h[st.top()][index]) st.pop(); l[i]=st.top(); st.push(i); } while(!st.empty()) st.pop(); h[n+1][index]=-1; st.push(n+1); for(int i=n;i>=1;i--){ while(!st.empty()&&h[i][index]<=h[st.top()][index]) st.pop(); r[i]=st.top(); st.push(i); } ans=0; for(int i=1;i<=n;i++){ ans=max(ans,(r[i]-l[i]-1)*h[i][index]); } return ans; } signed main(){ IO; cin>>m>>n; char x; for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ cin>>x; if(x=='F') h[j][i]=h[j][i-1]+1; else h[j][i]=0; } } int maxx =-1; for(int i=1;i<=m;i++) maxx=max(maxx,get(i)); cout<<maxx*3; return 0; }
信息
- ID
- 63
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 1
- 标签
- 递交数
- 82
- 已通过
- 59
- 上传者