• <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>
            posts - 74,  comments - 33,  trackbacks - 0
            Knights

            Time limit: 10sec. Submitted: 167
            Memory limit: 32M Accepted: 58
            Source : BOI 2001

            We are given a chess-board of size n*n, from which some fields have been removed. The task is to determine the maximum number of knights that can be placed on the remaining fields of the board in such a way that none of them check each other.


            Fig.1: A knight placed on the field S checks fields marked with x.

            Task

            Write a program, that:

            • reads the description of a chess-board with some fields removed
            • determines the maximum number of knights that can be placed on the chess-board in such a way that none of them check each other,

            Input

            The first line of the input file contains two integers n and m, separated by a single space, 1<=n<=200, 0<=m<n2; n is the chess-board size and m is the number of removed fields. Each of the following m lines contains two integers: x and y, separated by a single space, 1<=x,y<=n -- these are the coordinates of the removed fields. The coordinates of the upper left corner of the board are (1,1), and of the bottom right are (n,n). The removed fields are not repeated in the file.

            There are multiple test cases. Process to end of file.

            Output

            The output should contain one integer (in the first and only line of the file). It should be the maximum number of knights that can be placed on the given chess-board without checking each other.

            Sample Input

            3 2
            1 1
            3 3
            

            Sample output

            5
            怎么說(shuō)呢,這道題。。。。。
            很無(wú)語(yǔ)。。。。開(kāi)始的時(shí)候我一直從x,y奇偶相同的的點(diǎn)尋找匹配,結(jié)果就TLE了N次。我很無(wú)語(yǔ)。。。。。
            我想我的匹配也是鄰接表的。。。。為什么那么多AC的而我吧卻是TLE呢,我抱著試試看的想法改成從奇偶性不同的點(diǎn)
            開(kāi)始尋找匹配,結(jié)果AC。。。。。我無(wú)語(yǔ)。。。。不知道該如何是好。。。。。。。
            二分最大匹配代碼如下:
            int?H(int?t)?{?
            ????
            int?i;?
            ????
            for(i=0;i<v[t].size();i++)?{?
            ???????
            if(flag[v[t][i]]==0)?{?
            ???????????flag[v[t][i]]
            =1;?
            ???????????
            if(pre[v[t][i]]==-1?||?H(pre[v[t][i]]))?{?
            ??????????????pre[v[t][i]]
            =t;?
            ??????????????
            return?1;?
            ???????????}
            ?
            ???????}
            ?
            ????}
            ?
            ????
            return?0;?
            }
            ?
            int?MaxMatch()?{?
            ????
            int?i,num;?
            ????memset(pre,
            0xff,sizeof(pre));?
            ????
            for(num=0,i=1;i<odd;i++){?
            ????????
            if(!v[i].size())continue;
            ???????????memset(flag,
            0,sizeof(flag));?
            ???????????
            if(H(i))num++;??
            ????}
            ?
            ????
            return?num;?
            }
            總之,最近就是TMD不開(kāi)心。。。。想想干這行,真不容易。。。尤其是在這個(gè)雞不生蛋,鳥(niǎo)不拉屎的地方。。。。。
            有句話怎么說(shuō)的,太陽(yáng)啊!!!
            不管怎么說(shuō),自己還是要好好學(xué)習(xí)真正有用的東西。。。。。
            我已經(jīng)落下許多。。。。。。。。。
            Good Good study.......
            Day Day up........
            posted on 2009-03-12 20:09 KNIGHT 閱讀(344) 評(píng)論(2)  編輯 收藏 引用

            FeedBack:
            # re: Knights
            2011-08-23 21:53 | Lightning
            請(qǐng)問(wèn)您說(shuō)的奇偶性不同的x,y是指什么?  回復(fù)  更多評(píng)論
              
            # re: Knights
            2011-08-24 19:34 | Lightning
            我用PASCAL寫(xiě)的程序倒數(shù)第二個(gè)點(diǎn)過(guò)不了
            200 4
            3 1
            3 2
            3 3
            2 3
            這個(gè)點(diǎn)提示一會(huì)是爆棧一會(huì)是超時(shí),就算用了您說(shuō)的奇偶性不同也無(wú)濟(jì)于事。。。  回復(fù)  更多評(píng)論
              

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            <2008年12月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            天堂无码久久综合东京热| 久久婷婷五月综合色99啪ak| 久久只有这里有精品4| 久久精品国产久精国产果冻传媒| 性欧美大战久久久久久久久 | 欧美亚洲日本久久精品| 思思久久99热免费精品6| 久久精品国产亚洲av高清漫画 | 亚洲伊人久久大香线蕉综合图片 | 精品人妻伦九区久久AAA片69| 久久亚洲AV永久无码精品| 亚洲AV成人无码久久精品老人| 青青草原综合久久大伊人精品| 亚洲精品成人久久久| 国内精品久久久久久99蜜桃| 亚洲国产成人精品91久久久| 久久国产乱子伦精品免费强| 日韩精品久久无码中文字幕| 亚洲精品NV久久久久久久久久| 国产精品久久久久久搜索| 久久久噜噜噜久久中文字幕色伊伊 | 国产高清国内精品福利99久久| 欧洲成人午夜精品无码区久久 | 久久精品国产亚洲7777| 情人伊人久久综合亚洲| 人妻精品久久无码区| 久久人与动人物a级毛片| 三级片免费观看久久| 精品久久久久久无码国产| 国产精品成人精品久久久| 青青青伊人色综合久久| 久久精品国产亚洲沈樵| 国产成人精品免费久久久久| 亚洲精品国精品久久99热一| 久久精品卫校国产小美女| 中文字幕久久波多野结衣av| 久久久久久久精品成人热色戒 | 久久精品国产WWW456C0M| 伊人久久大香线蕉精品| 99久久精品国产一区二区三区 | 国产精品久久波多野结衣|