• <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
            這道題沒什么,一道BFS而已,只是數據有點問題,看了Discuss才知道有超出300的數據我一生氣就開了500,開始RE,后來一次AC,唯一值得紀念的就是用了STL的queue寫了BFS,下次看來要用stack寫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 閱讀(168) 評論(0)  編輯 收藏 引用
            <2009年5月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            欧美一级久久久久久久大| 综合人妻久久一区二区精品| 97久久超碰成人精品网站| 狠狠88综合久久久久综合网| 99精品国产在热久久无毒不卡| 99久久免费国产精品热| 国内精品久久久久影院网站 | 中文字幕久久久久人妻| 久久男人Av资源网站无码软件| 免费观看久久精彩视频| 久久人人爽人人爽人人爽| A狠狠久久蜜臀婷色中文网| 亚洲精品乱码久久久久久蜜桃| 久久精品aⅴ无码中文字字幕重口| 99久久国产综合精品五月天喷水 | 久久免费高清视频| 国产aⅴ激情无码久久| 国产精品一区二区久久精品无码| 少妇熟女久久综合网色欲| 精品免费tv久久久久久久| 久久亚洲AV无码精品色午夜麻豆| 久久香蕉国产线看观看乱码| 综合人妻久久一区二区精品| 久久精品无码免费不卡| 久久精品中文闷骚内射| 久久国产AVJUST麻豆| 日韩一区二区久久久久久| 欧美一区二区三区久久综| 国内精品久久久久久中文字幕| 99久久99久久久精品齐齐| 伊人久久综合成人网| 久久精品卫校国产小美女| 久久午夜福利电影| 久久精品国产精品亚洲人人| 精品久久久久久国产91| 久久精品a亚洲国产v高清不卡| 久久精品国产乱子伦| 99精品国产综合久久久久五月天| 一级a性色生活片久久无少妇一级婬片免费放 | 亚洲精品无码久久久久去q| 亚洲精品综合久久|