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

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


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


 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 閱讀(400) 評論(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>
            亚洲欧美日韩成人| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 久久精品亚洲| 亚洲少妇中出一区| 欧美+日本+国产+在线a∨观看| 日韩一区二区电影网| 亚洲免费在线观看视频| 日韩一级网站| 欧美久色视频| 欧美国产精品一区| 国产一区自拍视频| 午夜在线播放视频欧美| 亚洲视频网在线直播| 久久综合成人精品亚洲另类欧美| 亚洲精品资源| 欧美日韩妖精视频| 亚洲福利在线视频| 激情欧美一区二区| 久久久久久久波多野高潮日日| 国产女人aaa级久久久级| 日韩视频在线观看| 在线天堂一区av电影| 欧美激情在线| 亚洲视频免费观看| 欧美一区二区精品| 国产欧美一区二区色老头| 一本色道久久综合亚洲精品按摩| 篠田优中文在线播放第一区| 欧美一区精品| 在线免费观看视频一区| 美国十次了思思久久精品导航| 欧美激情一区二区三区| 日韩系列在线| 国产日韩欧美三级| 久久婷婷国产综合尤物精品| 亚洲国产精品久久人人爱蜜臀 | 亚洲国产精品尤物yw在线观看| 免费看的黄色欧美网站| 最新亚洲一区| 欧美人妖在线观看| 亚洲精品午夜| 欧美精品一区二区精品网| 亚洲一区二区三区免费观看| 国产自产2019最新不卡| 能在线观看的日韩av| 亚洲一区精品电影| 免费在线观看日韩欧美| 亚洲免费中文| 欧美a级片网站| 午夜精品久久久99热福利| 欧美成人在线网站| 久久不见久久见免费视频1| 亚洲精品欧美在线| 黄色成人av在线| 国产精品久久久久婷婷| 欧美激情视频一区二区三区免费| 国产一区二区日韩精品欧美精品| 欧美国产一区二区| 久久av资源网| 亚洲欧美制服另类日韩| 亚洲精品国产精品国产自| 老司机午夜免费精品视频| 午夜伦理片一区| 亚洲自拍偷拍一区| 99精品欧美一区二区蜜桃免费| 伊人精品在线| 亚洲激情偷拍| 国产九色精品成人porny| 欧美日韩不卡在线| 欧美久久久久久久久| 欧美黄色一级视频| 欧美高清影院| 欧美日韩极品在线观看一区| 欧美国产第一页| 亚洲欧洲日本在线| 久久精品国产一区二区三| 欧美在线视频一区二区| 亚洲欧美在线一区二区| 欧美一二区视频| 久久精品99国产精品酒店日本| 久久av老司机精品网站导航| 久久精品国产第一区二区三区| 欧美一区二区私人影院日本| 久久精品av麻豆的观看方式| 久久精品国产77777蜜臀| 米奇777在线欧美播放| 亚洲精品一区久久久久久| 一区二区三区日韩精品| 性欧美8khd高清极品| 亚洲欧美一区二区精品久久久| 欧美一区二区日韩一区二区| 欧美中文字幕在线| 欧美精品久久久久久久久老牛影院 | 一本色道久久综合亚洲精品婷婷| 亚洲日本电影在线| 亚洲一区二区三区精品在线| 午夜精品在线视频| 欧美成人资源| 国产午夜精品全部视频播放| 亚洲精品1区2区| 亚洲综合色噜噜狠狠| **性色生活片久久毛片| 亚洲天堂av高清| 噜噜噜躁狠狠躁狠狠精品视频| 亚洲黄色精品| 久久久www成人免费精品| 欧美午夜精品久久久久久超碰| 国产亚洲第一区| 亚洲深夜福利| 久久久噜噜噜久久| 亚洲国产精品va在线看黑人| 亚洲欧美在线一区二区| 欧美日韩专区| 99在线热播精品免费99热| 欧美va天堂| 久久久久91| 激情一区二区三区| 久久久综合激的五月天| 亚洲欧美日韩国产| 国产精品高潮在线| 一本久久精品一区二区| 一本大道av伊人久久综合| 欧美成人视屏| 噜噜噜在线观看免费视频日韩| 韩国成人精品a∨在线观看| 久久九九全国免费精品观看| 亚洲一区二区视频在线| 国产乱子伦一区二区三区国色天香| 亚洲一区二区精品在线| 一区二区三区黄色| 亚洲免费观看视频| 欧美电影美腿模特1979在线看| 亚洲国产高清在线| 国产欧美一区在线| 一本久道综合久久精品| 亚洲免费影视| 激情综合五月天| 亚洲国产视频一区二区| 欧美女人交a| 久久久国产亚洲精品| 久久视频在线视频| 一本色道久久综合亚洲精品高清| 一本色道久久综合亚洲精品小说| 亚洲主播在线观看| 伊人久久成人| 一区二区高清在线观看| 国产亚洲欧美aaaa| 亚洲精美视频| 国外精品视频| 99在线观看免费视频精品观看| 国产色婷婷国产综合在线理论片a| 浪潮色综合久久天堂| 亚洲日本免费电影| 欧美激情偷拍| 久久综合九色综合网站| 欧美日韩精品三区| 欧美**人妖| 国产亚洲成av人片在线观看桃| 亚洲国产精品国自产拍av秋霞| 国产精品嫩草99av在线| 亚洲精品在线一区二区| 狠狠入ady亚洲精品经典电影| 一本色道久久99精品综合| 亚洲第一在线综合网站| 国产精品少妇自拍| 亚洲裸体在线观看| 欧美天天在线| 亚洲免费观看高清完整版在线观看熊| 狠狠操狠狠色综合网| 亚洲男女自偷自拍| 亚洲一区在线观看视频| 欧美日韩日本视频| 亚洲国产精品一区制服丝袜| 一区二区亚洲| 美女视频黄 久久| 麻豆精品视频| 久久www成人_看片免费不卡| 亚洲午夜激情网站| 欧美天天在线| 亚洲伊人观看| 久久黄色级2电影| 激情综合电影网| 久久午夜视频| 亚洲激情在线视频| 在线性视频日韩欧美| 欧美午夜精品久久久久久久| 一本色道久久99精品综合| 亚洲欧美日韩国产一区| 国产日韩欧美在线| 看欧美日韩国产| 亚洲精品男同| 国内精品一区二区| 欧美 日韩 国产一区二区在线视频 | 久久av最新网址| 免费欧美电影| 亚洲一区二区三区精品在线观看 | 一本不卡影院| 久久久久国产精品厨房| 亚洲日韩第九十九页| 国产精品免费一区二区三区在线观看 |