1 条题解

  • 0
    @ 2025-10-8 16:50:07
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e3+10;
    int a[N][N];
    struct node{int d,w;};
    
    int main()
    {
    	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        int n,m;cin>>n>>m;
        memset(a,0,sizeof(a));
        char c; 
    	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
    	{
    		cin>>c;
    		if(c=='F')a[i][j]=a[i-1][j]+1;
    	}
        int ans=0;
    	for(int i=1;i<=n;i++)
    	{
    		stack<node> stk;
    		a[i][m+1]=0;
    		for(int j=1;j<=m+1;j++)
    		{
    			int w=0;
    			while( stk.size() && a[i][j]<stk.top().d )
    			{
    				w+=stk.top().w;
    				ans=max(ans, stk.top().d*w );
    				stk.pop();
    			}
    			stk.push(node{a[i][j],w+1});
    		}
    	}
        cout<<ans<<'\n';
        return 0;
    }
    
    • 1

    *【栈:单调栈】矩形的最大子矩阵面积City Game

    信息

    ID
    389
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    递交数
    207
    已通过
    53
    上传者