青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

coreBugZJ

此 blog 已棄。

Selling Land,nwerc2010 G

Selling Land
As you may know, the country of Absurdistan is full of abnormalities. For example, the whole
country can be divided into unit squares that are either grass or swamp. Also, the country
is famous for its incapable bureaucrats. If you want to buy a piece of land (called a parcel),
you can only buy a rectangular area, because they cannot handle other shapes. The price of
the parcel is determined by them and is proportional to the perimeter of the parcel, since the
bureaucrats are unable to multiply integers and thus cannot calculate the area of the parcel.

    Per owns a parcel in Absurdistan surrounded by swamp and he wants to sell it, possibly in
parts, to some buyers. When he sells a rectangular part of his land, he is obliged to announce
this to the local bureaucrats. They will first tell him the price he is supposed to sell it for. Then
they will write down the name of the new owner and the coordinates of the south-east corner
of the parcel being sold. If somebody else already owns a parcel with a south-east corner at
the same spot, the bureaucrats will deny the change of ownership.

    Per realizes that he can easily trick the system. He can sell overlapping areas, because
bureaucrats only check whether the south-east corners are identical. However, nobody wants
to buy a parcel containing swamp.

    In this example, dark squares represent swamp. Per may, for example, sell three overlapping grey
areas, with dimensions 2 × 1, 2 × 4 and 4 × 1 respectively. The total perimeter is 6 + 12 + 10 = 28.
Note that he can get more money by selling even more land. This figure corresponds to the case in
the sample input.

    Now Per would like to know how many parcels of each perimeter he needs to sell in order
to maximize his profit. Can you help him? You may assume that he can always find a buyer
for each piece of land, as long as it doesn’t contain any swamps. Also, Per is sure that no
square within his parcel is owned by somebody else.

Input
On the first line a positive integer: the number of test cases, at most 100. After that per test
case:
• One line with two integers n and m (1 ≤ n, m ≤ 1 000): the dimensions of Per’s parcel.
• n lines, each with m characters. Each character is either ‘#’ or ‘.’. The j-th character
on the i-th line is a ‘#’ if position (i, j) is a swamp, and ‘.’ if it is grass. The north-west
corner of Per’s parcel has coordinates (1, 1), and the south-east corner has coordinates
(n, m).

Output
Per test case:
• Zero or more lines containing a complete list of how many parcels of each perimeter
Per needs to sell in order to maximize his profit. More specifically, if Per should sell pi
parcels of perimeter i in the optimal solution, output a single line “pi x i”. The lines
should be sorted in increasing order of i. No two lines should have the same value of i,
and you should not output lines with pi = 0.

Sample in- and output

Input
1
6 5
..#.#
.#...
#..##
...#.
#....
#..#.

Output
6 x 4
5 x 6
5 x 8
3 x 10
1 x 12


比賽時(shí)就有思路,可惜時(shí)間不夠了,最后階段在沖刺另一題——可惜也是賽后幾分鐘才解決。。。


 1 #include <stdio.h>
 2 #include <string.h>
 3 
 4 #define  L  1009
 5 #define  T  (L*4)
 6 
 7 int n, m, cant[ L ][ L ], width[ L ][ L ], height[ L ][ L ];
 8 
 9 void input() {
10         int i, j;
11         char  tmp[ L ];
12         scanf( "%d%d"&n, &m );
13         gets( tmp );
14         for ( i = 1; i <= n; ++i ) {
15                 gets( tmp );
16                 for ( j = 0; j < m; ++j ) {
17                         cant[ i ][ j+1 ] = ( tmp[ j ] == '#' );
18                 }
19         }
20 }
21 
22 void solve() {
23         int i, j, k, most, up[ L ], left[ L ], right[ L ];
24         memset( width, 0sizeof(width) );
25         memset( height, 0sizeof(height) );
26         for ( j = 1; j <= m; ++j ) {
27                 up[ j ] = 1;
28                 left[ j ] = 1;
29                 right[ j ] = m;
30         }
31         for ( i = 1; i <= n; ++i ) {
32                 most = 1;
33                 for ( j = 1; j <= m; ++j ) {
34                         if ( cant[ i ][ j ] ) {
35                                 up[ j ] = i + 1;
36                                 left[ j ] = 1;
37                                 most = j + 1;
38                         }
39                         else if ( most > left[ j ] ) {
40                                 left[ j ] = most;
41                         }
42                 }
43 
44                 most = m;
45                 for ( j = m; j >= 1--j ) {
46                         if ( cant[ i ][ j ] ) {
47                                 most = j - 1;
48                                 right[ j ] = m;
49                         }
50                         else if ( right[ j ] > most ) {
51                                 right[ j ] = most;
52                         }
53                 }
54 
55                 up[ 0 ] = up[ 1 ] - 1;
56                 for ( j = 1; j <= m; ++j ) {
57                         if ( ( cant[ i ][ j ] ) || ( up[ j ] == up[ j - 1 ] ) ) {
58                                 continue;
59                         }
60                         for ( k = left[ j ]; k <= right[ j ]; ++k ) {
61                                 if ( (k-left[j]+1+ (i-up[j]+1> width[i][k] + height[i][k] ) {
62                                         width[ i ][ k ] = k - left[ j ] + 1;
63                                         height[ i ][ k ] = i - up[ j ] + 1;
64                                 }
65                         }
66                 }
67         }
68 }
69 
70 void output() {
71         int cnt[ T ], i, j;
72         memset( cnt, 0sizeof(cnt) );
73         for ( i = 1; i <= n; ++i ) {
74                 for ( j = 1; j <= m; ++j ) {
75                         ++cnt[ ( width[i][j] + height[i][j] ) << 1 ];
76                 }
77         }
78         for ( i = 1; i < T; ++i ) {
79                 if ( cnt[ i ] > 0 ) {
80                         printf( "%d x %d\n", cnt[ i ], i );
81                 }
82         }
83 }
84 
85 int main() {
86         int td;
87         scanf( "%d"&td );
88         while ( td-- > 0 ) {
89                 input();
90                 solve();
91                 output();
92         }
93         return 0;
94 }
95 

posted on 2011-04-29 21:05 coreBugZJ 閱讀(395) 評論(0)  編輯 收藏 引用 所屬分類: ACM

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产精品免费网站在线观看| 久久久www成人免费无遮挡大片| 欧美黑人国产人伦爽爽爽| 欧美激情视频网站| 亚洲精品乱码久久久久久久久 | 久久精品五月| 激情欧美日韩一区| 欧美mv日韩mv国产网站app| 亚洲日本免费电影| 性色一区二区三区| 精品999成人| 欧美日韩hd| 午夜欧美视频| 亚洲人成网站777色婷婷| 亚洲欧美日韩爽爽影院| 韩国精品一区二区三区| 欧美精品情趣视频| 欧美在线观看天堂一区二区三区| 欧美成人精品1314www| 在线一区亚洲| 一区二区亚洲精品| 国产精品激情av在线播放| 久久精品国产96久久久香蕉| 亚洲精品一区二区三区不| 久久大逼视频| 在线视频日韩| 激情欧美一区二区三区| 欧美欧美天天天天操| 久久av二区| 一区二区久久| 亚洲国产91| 久久久久高清| 亚洲一区二区三区乱码aⅴ| 尤物yw午夜国产精品视频明星| 欧美色视频日本高清在线观看| 久久久久久久久久久久久久一区 | 亚洲精品永久免费精品| 国产三级欧美三级日产三级99| 欧美日韩mp4| 久久久综合香蕉尹人综合网| 亚洲一区二区三区乱码aⅴ| 欧美大片91| 久久午夜电影网| 欧美制服丝袜第一页| 99精品99| 亚洲精品日韩久久| 亚洲国产成人精品久久| 国产亚洲精久久久久久| 国产精品国产a级| 欧美日韩国产三级| 欧美精品成人| 免费在线日韩av| 久久一区二区三区超碰国产精品| 午夜免费电影一区在线观看| 一区二区三区精品久久久| 亚洲人线精品午夜| 亚洲国产欧美一区| 亚洲国产精品成人va在线观看| 久久综合999| 久久综合久久综合久久综合| 欧美一区二区三区精品电影| 亚洲主播在线| 亚洲一区视频在线| 亚洲在线免费视频| 亚洲欧美日产图| 亚洲尤物在线| 午夜久久黄色| 午夜精品福利视频| 性欧美暴力猛交69hd| 亚洲男女自偷自拍| 午夜精品区一区二区三| 亚洲欧美视频在线观看| 午夜精品一区二区三区在线| 亚洲欧美一区二区在线观看| 亚洲女女女同性video| 亚洲永久免费| 欧美专区在线| 美女视频网站黄色亚洲| 欧美国产日韩a欧美在线观看| 奶水喷射视频一区| 亚洲国产婷婷香蕉久久久久久99| 亚洲国产婷婷综合在线精品| 亚洲精品免费在线播放| 亚洲桃花岛网站| 午夜在线观看欧美| 久久天天躁夜夜躁狠狠躁2022| 久久综合婷婷| 欧美日韩免费精品| 国产精品日日摸夜夜摸av| 国产在线视频不卡二| 亚洲高清av| 亚洲午夜电影网| 欧美在线国产精品| 免费视频一区二区三区在线观看| 欧美黄色网络| 亚洲视频免费看| 久久精品免费| 欧美日韩不卡| 国产真实乱偷精品视频免| 亚洲黄色性网站| 亚洲在线观看免费视频| 久久福利电影| 欧美激情亚洲视频| 亚洲在线一区二区三区| 久久青青草综合| 欧美性理论片在线观看片免费| 国产亚洲美州欧州综合国| 亚洲黄色毛片| 欧美怡红院视频一区二区三区| 毛片精品免费在线观看| 日韩小视频在线观看专区| 欧美亚洲一区二区三区| 欧美电影免费观看高清| 国产美女一区二区| 亚洲美女毛片| 久久久www| 99国产成+人+综合+亚洲欧美| 午夜精品久久久久久久久久久久| 欧美成人午夜激情| 国内精品久久久久久久97牛牛| 一本色道婷婷久久欧美| 久久这里只有| 亚洲——在线| 欧美日韩一区二区精品| 曰韩精品一区二区| 午夜精品福利在线| 亚洲国产精品成人综合色在线婷婷| 亚洲曰本av电影| 欧美日韩国产专区| 在线成人免费观看| 久久国产欧美精品| 一二三区精品| 欧美精品国产一区二区| 精品1区2区| 久久久久国内| 亚洲免费一级电影| 欧美日韩在线免费观看| 亚洲人成在线观看| 美女主播视频一区| 欧美一区影院| 国产视频欧美视频| 午夜在线播放视频欧美| 一区二区三区免费看| 欧美精品在线观看91| 亚洲人成人一区二区在线观看| 麻豆精品在线观看| 久久久99爱| 樱花yy私人影院亚洲| 久久精品欧洲| 性欧美长视频| 国产亚洲精品久久久久久| 午夜免费在线观看精品视频| 一区二区三区**美女毛片 | 欧美性片在线观看| 在线亚洲免费视频| 亚洲日韩欧美视频一区| 欧美激情麻豆| 亚洲最新视频在线播放| 91久久精品国产91久久性色| 欧美1区2区| 亚洲精品综合精品自拍| 最新中文字幕亚洲| 欧美精品一区二区久久婷婷| 亚洲精品日韩在线观看| 亚洲国产精品久久久久久女王| 欧美成人综合网站| 日韩视频永久免费观看| 亚洲三级影院| 国产精品福利影院| 欧美亚洲在线| 欧美一区午夜精品| 欲香欲色天天天综合和网| 欧美电影免费观看大全| 欧美成人一区二区在线| 一区二区三区不卡视频在线观看 | 亚洲精品影视在线观看| 欧美日韩一区二区三区在线视频 | 久久精品99| 亚洲欧洲精品一区二区| 亚洲精品久久久久久下一站| 欧美日韩国产在线播放网站| 亚洲女人天堂av| 久久精品二区亚洲w码| 亚洲激情不卡| 99国产精品视频免费观看| 国产精品女主播一区二区三区| 久久精品国产99国产精品澳门| 久久久久国产精品午夜一区| 亚洲精品美女91| 中国成人黄色视屏| 黄色亚洲免费| 亚洲精品视频免费观看| 国产麻豆日韩| 欧美激情视频在线播放| 欧美日韩日本视频| 久久国产精品久久国产精品| 久久中文精品| 亚洲欧美三级伦理| 免费看成人av| 欧美一级黄色录像|