记录编号 73593 评测结果 AAAAAAAAAA
题目名称 [Nescafé 20] 玉蟾宫 最终得分 100
用户昵称 GravatarEzoi_XY 是否通过 通过
代码语言 Pascal 运行时间 0.269 s
提交时间 2013-10-22 09:43:56 内存使用 0.18 MiB
显示代码纯文本
Program cog1237;
    Var
        L,R,H,K:Array[0..1010]Of Longint;
        A:Array[0..1010]Of Char;
        N,M,S,I,J,T:Longint;
    Begin
        Assign(Input,'jademoon.in');
        Assign(Output,'jademoon.out');
        Reset(Input);
        Rewrite(Output);
        Readln(N,M);
        While Eoln Do Readln;
        Fillchar(H,Sizeof(H),0);
        S:=0;
        Repeat
            T:=0;
            K[0]:=0;
            For I:=1 To M Do
                Begin
                    Read(A[I],A[I+1]);
                    If A[I]='F'
                        Then Begin
                                 Inc(H[I]);
                                 While (T<>0) And (H[K[T]]>=H[I]) Do Dec(T);
                                 L[I]:=K[T];
                                 Inc(T);
                                 K[T]:=I;
                             End
                        Else Begin
                                 H[I]:=0;
                                 While (T<>0) And (H[K[T]]>=H[I]) Do Dec(T);
                                 Inc(T);
                                 K[T]:=I;
                                 L[I]:=I;
                             End;
                End;
            T:=0;
            K[0]:=M+1;
            For I:=M Downto 1 Do
                If A[I]='F'
                    Then Begin
                             While (T<>0) And (H[K[T]]>=H[I]) Do Dec(T);
                             R[I]:=K[T];
                             Inc(T);
                             K[T]:=I;
                             If S<(R[I]-L[I]-1)*H[I] Then S:=(R[I]-L[I]-1)*H[I];
                         End
                    Else Begin
                             While (T<>0) And (H[K[T]]>=H[I]) Do Dec(T);
                             Inc(T);
                             K[T]:=I;
                             R[I]:=I;
                         End;
            Readln;
            Dec(N);
        Until N=0;
        Writeln(S*3);
        Close(Input);
        Close(Output);
    End.