• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            gzwzm06

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              1 隨筆 :: 52 文章 :: 17 評論 :: 0 Trackbacks

            用PKU 2559的思路
            跟2559一樣還有DP解法:路徑壓縮

              1
              2#include <cstdio>
              3#include <cstring>
              4
              5const int SIZE = 1002 ;
              6
              7struct STACK
              8{
              9    int ht ;
             10    int pos ;
             11}
             ;
             12
             13STACK stack[SIZE] ;
             14int top ;
             15
             16int row , col , height[SIZE] ;
             17
             18int GetMaxArea()
             19{
             20    int ans , temp ;
             21    int i ;
             22    
             23    top  = 0 ;
             24    
             25    stack[top].ht = height[0] ;
             26    stack[top].pos = 0 ;
             27    ans = height[0] ;
             28    height[col] = 0 ;
             29
             30    for ( i = 1 ; i <= col ; ++i )
             31    {
             32        if ( height[i] <= stack[top].ht )
             33        {
             34            while ( top >= 0 && height[i] <= stack[top].ht )
             35            {
             36                temp = stack[top].ht * (i - stack[top].pos) ;
             37
             38                if ( temp > ans )
             39                    ans = temp ;
             40
             41                top-- ;
             42            }

             43            top++ ;
             44            stack[top].ht = height[i] ;
             45        }

             46        else {
             47            stack[++top].ht = height[i] ;
             48            stack[top].pos = i ;
             49        }

             50    }

             51        
             52    return ans ;
             53}

             54
             55
             56
             57int main()
             58{
             59    //freopen("1.txt", "r", stdin) ;
             60
             61    int test ;
             62    int maxProfit , temp , i , j ;
             63    char ch ;
             64
             65    scanf("%d"&test) ;
             66
             67    while ( test-- )
             68    {
             69
             70        scanf("%d %d"&row, &col) ;
             71        getchar() ;
             72
             73        maxProfit = 0 ;
             74
             75        j = 0 ;
             76
             77        while ( true ) {
             78            ch = getchar() ;
             79
             80            if ( ch == 'R' ) {
             81                height[j++= 0 ;
             82            }

             83            else if ( ch == 'F' ) {
             84                height[j++= 1 ;
             85            }

             86
             87            if ( j == col )
             88                break ;
             89        }

             90
             91
             92        for ( i = 1 ; i < row ; ++i )
             93        {
             94            j = 0 ;
             95
             96            while ( true ) {
             97                ch = getchar() ;
             98
             99                if ( ch == 'R' ) {
            100                    height[j++= 0 ;
            101                }

            102                else if ( ch == 'F' ) {
            103                    height[j++]++ ;
            104                }

            105
            106                if ( j == col )
            107                    break ;
            108            }

            109        
            110            temp = GetMaxArea() ;
            111
            112            if ( temp > maxProfit )
            113                maxProfit = temp ;
            114        }

            115
            116        printf("%d\n", (maxProfit * 3)) ;
            117
            118
            119    }

            120    return 0 ;
            121}

            122
            posted on 2009-03-05 23:56 閱讀(288) 評論(0)  編輯 收藏 引用 所屬分類: DP
            色综合合久久天天给综看| 久久婷婷人人澡人人爽人人爱| 欧美亚洲日本久久精品| 久久96国产精品久久久| 亚洲va中文字幕无码久久不卡| 久久综合九色欧美综合狠狠| 麻豆精品久久精品色综合| 久久久久久狠狠丁香| 18岁日韩内射颜射午夜久久成人 | 久久青青草原国产精品免费| 久久天天躁狠狠躁夜夜网站| 久久精品无码专区免费青青| 国产一区二区精品久久| 国产精品九九久久免费视频| 久久久久久噜噜精品免费直播| 久久久久国色AV免费看图片| 亚洲精品乱码久久久久久蜜桃 | 午夜天堂精品久久久久| 色婷婷综合久久久久中文| 久久久久人妻一区二区三区vr| 欧美黑人激情性久久| 国产精品激情综合久久| 久久精品综合网| 少妇久久久久久久久久| 久久精品国产久精国产思思| 99精品久久久久久久婷婷| 久久久国产亚洲精品| 久久影院综合精品| 精品国产青草久久久久福利| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 欧美日韩精品久久久免费观看| 久久婷婷五月综合色奶水99啪| 久久久国产乱子伦精品作者| 伊人色综合久久天天| 国产99久久久国产精品小说| 狠狠狠色丁香婷婷综合久久五月 | 秋霞久久国产精品电影院| 中文精品99久久国产| 久久精品免费一区二区三区| 亚洲国产成人久久笫一页| 狠狠色丁香久久综合五月|