• <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
            Meteor Shower
            Time Limit: 1000MS Memory Limit: 65536K
            Total Submissions: 2467 Accepted: 676

            Description

            Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her way to a safe location (one that is never destroyed by a meteor) . She is currently grazing at the origin in the coordinate plane and wants to move to a new, safer location while avoiding being destroyed by meteors along her way.

            The reports say that M meteors (1 ≤ M ≤ 50,000) will strike, with meteor i will striking point (Xi, Yi) (0 ≤ Xi ≤ 300; 0 ≤ Yi ≤ 300) at time Ti (0 ≤ Ti? ≤ 1,000). Each meteor destroys the point that it strikes and also the four rectilinearly adjacent lattice points.

            Bessie leaves the origin at time 0 and can travel in the first quadrant and parallel to the axes at the rate of one distance unit per second to any of the (often 4) adjacent rectilinear points that are not yet destroyed by a meteor. She cannot be located on a point at any time greater than or equal to the time it is destroyed).

            Determine the minimum time it takes Bessie to get to a safe place.

            Input

            * Line 1: A single integer: M
            * Lines 2..M+1: Line i+1 contains three space-separated integers: Xi, Yi, and Ti

            Output

            * Line 1: The minimum time it takes Bessie to get to a safe place or -1 if it is impossible.

            Sample Input

            4
            0 0 2
            2 1 2
            1 1 2
            0 3 5
            

            Sample Output

            5
            

            Source

            USACO 2008 February Silver
            這道題沒(méi)什么,一道BFS而已,只是數(shù)據(jù)有點(diǎn)問(wèn)題,看了Discuss才知道有超出300的數(shù)據(jù)我一生氣就開(kāi)了500,開(kāi)始RE,后來(lái)一次AC,唯一值得紀(jì)念的就是用了STL的queue寫(xiě)了BFS,下次看來(lái)要用stack寫(xiě)DFS了的確很是方便,部分代碼如下:
            while(!q.empty()){
            ????????????point
            =q.front();
            ????????????a
            =point.x,b=point.y;
            ????????????
            if(flag[a][b]==0)break;
            ????????????
            for(int?i=0;i<4;i++){
            ????????????????
            int?x=a+dir[i][0];
            ????????????????
            int?y=b+dir[i][1];
            ????????????????
            if(OK(x,y)&&(map[x][y]==0||map[x][y]>map[a][b]+1)){
            ????????????????????
            if(map[x][y])flag[x][y]=1;
            ????????????????????map[x][y]
            =map[a][b]+1;
            ????????????????????point.x
            =x,point.y=y;
            ????????????????????q.push(point);????
            ????????????????}

            ????????????}

            ????????????q.pop();????????
            ????????}

            posted on 2009-03-30 09:50 KNIGHT 閱讀(169) 評(píng)論(0)  編輯 收藏 引用

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


            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久www免费人成精品香蕉| 中文字幕无码久久久| 国内精品久久久久影院一蜜桃| 久久婷婷国产剧情内射白浆 | 精品久久久久久无码免费| 国内精品久久久久国产盗摄| 午夜福利91久久福利| 久久综合给久久狠狠97色| 国产精品亚洲综合专区片高清久久久| 久久亚洲国产成人影院网站| 久久久一本精品99久久精品88| 久久综合九色综合97_久久久| 超级97碰碰碰碰久久久久最新| 日韩亚洲欧美久久久www综合网 | 久久久久亚洲AV成人网人人软件| 天天影视色香欲综合久久| 久久亚洲精品成人AV| 日本久久久久久久久久| 99久久精品国产免看国产一区| 色欲综合久久躁天天躁| 秋霞久久国产精品电影院| 国产人久久人人人人爽| 亚洲精品乱码久久久久久蜜桃图片 | 久久天堂AV综合合色蜜桃网| 国产精品成人无码久久久久久 | 久久大香香蕉国产| 亚洲精品乱码久久久久久中文字幕| 色欲综合久久躁天天躁| 久久久精品一区二区三区| av午夜福利一片免费看久久| 漂亮人妻被黑人久久精品| 无码国内精品久久人妻蜜桃| 久久久午夜精品| 久久中文字幕人妻熟av女| 久久国产V一级毛多内射| 久久久久亚洲爆乳少妇无| 久久久久亚洲AV无码去区首| 内射无码专区久久亚洲| 人人狠狠综合久久亚洲| 亚洲成av人片不卡无码久久| 久久久青草青青国产亚洲免观|