hdu 1505 City Game(hdu1506的二維推廣),hduhdu1506

來源:互聯網
上載者:User

hdu 1505 City Game(hdu1506的二維推廣),hduhdu1506

1.輸入的時候資料的時候要注意

2.1506的二維推廣

代碼:

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int INF=1<<30;int a[1005][1005];int L[1005];int R[1005];int main(){    int t;    int m,n;    int ans;    char s[10];    scanf("%d",&t);    memset(a,0,sizeof(a));    while(t--)    {        scanf("%d%d",&m,&n);        for(int i=1;i<=m;i++)        {            for(int j=1;j<=n;j++)            {                scanf("%s",s);                if(s[0]=='F')                    a[i][j]=1;                else                    a[i][j]=0;            }        }        ans=-INF;        for(int i=1;i<=m;i++)        {            for(int j=1;j<=n;j++)            {                if(a[i][j]==1)                    a[i][j]+=a[i-1][j];            }            for(int j=1;j<=n;j++)            {                L[j]=j;                while(L[j]>1&&a[i][L[j]-1]>=a[i][j])                    L[j]=L[L[j]-1];            }            for(int j=n;j>=1;j--)            {                R[j]=j;                while(R[j]<n&&a[i][R[j]+1]>=a[i][j])                    R[j]=R[R[j]+1];            }            for(int j=1;j<=n;j++)            {                ans=max(ans,a[i][j]*(R[j]-L[j]+1));            }        }        printf("%d\n",3*ans);    }    return 0;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.