• 「Poetize4」玉蟾宫


    描述 Description
    这片土地被分成N*M个格子,每个格子里写着'R'或者'F',R代表这块土地被赐予了rainbow,F代表这块土地被赐予了freda。
    现在freda要在这里卖萌。。。它要找一块矩形土地,要求这片土地都标着'F'并且面积最大。
    但是rainbow和freda的OI水平都弱爆了,找不出这块土地,而蓝兔也想看freda卖萌(她显然是不会编程的……),所以它们决定,如果你找到的土地面积为S,它们每人给你S两银子。
    题解:
    类似与ZJOI2007制作棋盘,这叫悬线法?我感觉就是一个单调栈而已。。。
    代码:
     1 #include<cstdio>
     2 
     3 #include<cstdlib>
     4 
     5 #include<cmath>
     6 
     7 #include<cstring>
     8 
     9 #include<algorithm>
    10 
    11 #include<iostream>
    12 
    13 #include<vector>
    14 
    15 #include<map>
    16 
    17 #include<set>
    18 
    19 #include<queue>
    20 
    21 #include<string>
    22 
    23 #define inf 1000000000
    24 
    25 #define maxn 1200
    26 
    27 #define maxm 500+100
    28 
    29 #define eps 1e-10
    30 
    31 #define ll long long
    32 
    33 #define pa pair<int,int>
    34 
    35 #define for0(i,n) for(int i=0;i<=(n);i++)
    36 
    37 #define for1(i,n) for(int i=1;i<=(n);i++)
    38 
    39 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
    40 
    41 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
    42 
    43 #define mod 1000000007
    44 
    45 using namespace std;
    46 
    47 inline int read()
    48 
    49 {
    50 
    51     int x=0,f=1;char ch=getchar();
    52 
    53     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    54 
    55     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    56 
    57     return x*f;
    58 
    59 }
    60 int n,m,ans,h[maxn],l[maxn],r[maxn],sta[maxn];
    61 
    62 int main()
    63 
    64 {
    65 
    66     freopen("input.txt","r",stdin);
    67 
    68     freopen("output.txt","w",stdout);
    69 
    70     n=read();m=read();
    71     h[0]=h[m+1]=-1;
    72     for1(i,n)
    73     {
    74         for1(j,m)
    75         {
    76             char ch=' ';
    77             while(ch!='F'&&ch!='R')ch=getchar();
    78             if(ch=='F')h[j]++;else h[j]=0;
    79         }
    80         int top=0;
    81         for1(j,m+1)
    82         {
    83             while(top&&h[j]<h[sta[top]])r[sta[top--]]=j-1;
    84             sta[++top]=j;
    85         }
    86         top=0;
    87         for3(j,m,0)
    88         {
    89             while(top&&h[j]<h[sta[top]])l[sta[top--]]=j+1;
    90             sta[++top]=j;
    91         }
    92         for1(j,m)ans=max(ans,h[j]*(r[j]-l[j]+1));
    93     }
    94     printf("%d
    ",3*ans);
    95 
    96     return 0;
    97 
    98 }
    View Code
  • 相关阅读:
    电脑开机自动上线(电脑开机之后自动将电脑的远程端口映射到服务器,可以通过其他设备进行连接,实现随时访问自己的电脑)
    批处理(bat)用来监测Windows网络状态脚本
    js取消点击事件
    uni-app 几个实用的功能
    前端几个比较方便的正则验证
    element.ui时间选择器
    Vue pc端项目打包后在nginx中无法正常浏览,点击页面出现404
    微信小程序之选项卡的实现方法
    文本溢出显示省略号
    分享几道前端面试题(3)
  • 原文地址:https://www.cnblogs.com/zyfzyf/p/4045536.html
Copyright © 2020-2023  润新知