• <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>

            poj3020

            Antenna Placement
            Time Limit: 1000MS Memory Limit: 65536K
            Total Submissions: 4127 Accepted: 2032

            Description

            The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discovery of a new, highly noise resistant, antenna. It is called 4DAir, and comes in four types. Each type can only transmit and receive signals in a direction aligned with a (slightly skewed) latitudinal and longitudinal grid, because of the interacting electromagnetic field of the earth. The four types correspond to antennas operating in the directions north, west, south, and east, respectively. Below is an example picture of places of interest, depicted by twelve small rings, and nine 4DAir antennas depicted by ellipses covering them.

            Obviously, it is desirable to use as few antennas as possible, but still provide coverage for each place of interest. We model the problem as follows: Let A be a rectangular matrix describing the surface of Sweden, where an entry of A either is a point of interest, which must be covered by at least one antenna, or empty space. Antennas can only be positioned at an entry in A. When an antenna is placed at row r and column c, this entry is considered covered, but also one of the neighbouring entries (c+1,r),(c,r+1),(c-1,r), or (c,r-1), is covered depending on the type chosen for this particular antenna. What is the least number of antennas for which there exists a placement in A such that all points of interest are covered?

            Input

            On the first row of input is a single positive integer n, specifying the number of scenarios that follow. Each scenario begins with a row containing two positive integers h and w, with 1 <= h <= 40 and 0 < w <= 10. Thereafter is a matrix presented, describing the points of interest in Sweden in the form of h lines, each containing w characters from the set ['*','o']. A '*'-character symbolises a point of interest, whereas a 'o'-character represents open space.

            Output

            For each scenario, output the minimum number of antennas necessary to cover all '*'-entries in the scenario's matrix, on a row of its own.

            Sample Input

            2
            7 9
            ooo**oooo
            **oo*ooo*
            o*oo**o**
            ooooooooo
            *******oo
            o*o*oo*oo
            *******oo
            10 1
            *
            *
            *
            o
            *
            *
            *
            *
            *
            *
            

            Sample Output

            17
            5
             
            思路:二分圖匹配,最小路徑覆蓋,建圖是按自己的感覺建的相鄰的兩個連邊,(v,u),(u,v)都加到圖里面,然后最大匹配就是原先的兩倍(不明白)
            再然后答案是總點數n-匹配數x
            若最大匹配為X,已蓋點(指的是兩個一組被一個基站覆蓋)個數=2*x,未蓋點=sum(總點數)-已蓋點=sum-2*x應為未蓋點肯定是單的,
            所以覆蓋未蓋點的基站個數肯定與未蓋點個數一樣=sum-s*x所以總的基站數為  x+sum-2*x=sum-x
            代碼
             1#include<stdio.h>
             2#include<string.h>
             3#include<math.h>
             4#define MAXSIZE 405
             5int dd[4][2]= {{-1,0},{1,0},{0,1},{0,-1}};
             6int result[MAXSIZE+1];
             7short data[MAXSIZE+1][MAXSIZE+1],state[MAXSIZE+1];
             8int h[45][20];
             9int n,m,sum,ans;
            10char map[45][20];
            11void init()
            12{
            13    int i,j,k;
            14    int xx,yy;
            15    sum=0;
            16    memset(result,0,sizeof(result));
            17    memset(data,0,sizeof(data));
            18    scanf("%d%d",&n,&m);
            19    for (i=0; i<n ; i++ )
            20    {
            21        scanf("%s",&map[i]);
            22        for (j=0; j<m ; j++ )
            23            if (map[i][j]=='*')
            24            {
            25                sum++;
            26                h[i][j]=sum;
            27            }

            28    }

            29    for (i=0; i<n ; i++)
            30        for (j=0; j<m; j++)
            31            if (map[i][j]=='*')
            32            {
            33                for (k=0; k<=3; k++)
            34                {
            35                    xx=i+dd[k][0];
            36                    yy=j+dd[k][1];
            37                    if (xx>=0&&yy>=0&&xx<n&&yy<m&&map[xx][yy]=='*')
            38                        data[h[i][j]][h[xx][yy]]=1;
            39                }

            40            }

            41}

            42int find(int a)
            43{
            44    int i;
            45    for (i=1; i<=sum ; i++ )
            46    {
            47        if (data[a][i]==1&&!state[i])
            48        {
            49            state[i]=1;
            50            if (result[i]==0||find(result[i]))
            51            {
            52                result[i]=a;
            53                return 1;
            54            }

            55        }

            56    }

            57    return 0;
            58}

            59int main()
            60{
            61    int t,i,j;
            62    scanf("%d",&t);
            63    for (i=1; i<=t ; i++ )
            64    {
            65        ans=0;
            66        init();
            67        for (j=1; j<=sum ; j++ )
            68        {
            69            memset(state,0,sizeof(state));
            70            if (find(j)) ans++;
            71        }

            72        printf("%d\n",sum-ans/2);
            73    }

            74    return 0;
            75}

            76

             

            posted on 2012-02-02 12:56 jh818012 閱讀(180) 評論(0)  編輯 收藏 引用

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內容較長,點擊標題查看
            • --王私江
            久久精品中文字幕一区| 色婷婷综合久久久中文字幕| 66精品综合久久久久久久| 久久久久免费精品国产| 日韩欧美亚洲国产精品字幕久久久| 国产福利电影一区二区三区久久老子无码午夜伦不 | 色88久久久久高潮综合影院 | 无码任你躁久久久久久| 性欧美大战久久久久久久久| 国产精品久久久久9999| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 亚洲中文字幕无码久久精品1| 国产精品对白刺激久久久| 欧洲性大片xxxxx久久久| 久久午夜羞羞影院免费观看| 精品综合久久久久久88小说| 午夜天堂av天堂久久久| 久久久综合香蕉尹人综合网| 久久精品人人做人人妻人人玩| 久久久久综合中文字幕| 久久99国产精品一区二区| 久久亚洲AV成人无码软件| 色综合久久综精品| 久久精品国产清高在天天线| 亚洲日韩欧美一区久久久久我| 色综合久久久久网| 久久99精品国产一区二区三区| 亚洲国产一成人久久精品| 香蕉99久久国产综合精品宅男自 | 久久青青草原亚洲av无码app| 色婷婷久久综合中文久久一本| 久久久久久久尹人综合网亚洲 | 午夜精品久久久久久久无码| 久久露脸国产精品| 久久久精品久久久久特色影视| 久久久九九有精品国产| 69国产成人综合久久精品| 伊人久久精品无码av一区| 久久精品国产99国产精品导航| 国产精品久久久久久久人人看| 色狠狠久久综合网|