<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      BiuのACM
      堅持是一種餅~

      題意: 把地面看做第一象限的網格,有場流星雨,會下M顆流星,流星落到地面某一格會摧毀那一格和上下左右四格,這些地方之后都不能再走?,F在Bessie 從[0,0]格出發,給你每一顆流星落到地面的坐標(整點)和時間,問Bessie最少用多少時間才能走到永遠安全的點上,如果走不到輸出-1。

      思路:讀入點和時間,然后在[301, 301]的網格上預處理,存入該點最先被摧毀的時間,然后在bfs的時候比較。永遠不能到達標記為INT_MAX。

      AC代碼:

       1 #include <iostream>
       2 #include <cstdio>
       3 #include <algorithm>
       4 #include <vector>
       5 #include <queue>
       6 #include <cstring>
       7 #include <climits>
       8 using namespace std;
       9 
      10 int m;
      11 int const maxn = 302;
      12 int const mde = 50004;
      13 struct node
      14 {
      15     int x, y, t;
      16     bool operator < (const node that) const {
      17         return t < that.t;
      18     }
      19     node() {x = y = t = 0;}
      20 };
      21 int mp[maxn][maxn];
      22 int dir[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
      23 bool border(int x, int y)
      24 {
      25     if(x < 0 || y < 0 || y > 301 || x > 301) return false;
      26     return true;
      27 }
      28 void init()
      29 {
      30     for(int i = 0; i < maxn; i++) {
      31         for(int j = 0; j < maxn; j++) mp[i][j] = INT_MAX;
      32     }
      33     for(int i = 0; i < m; i++) {
      34         int a, b, c; scanf("%d%d%d", &a, &b, &c);
      35         if(c < mp[a][b]) mp[a][b] = c;
      36         for(int j = 0; j < 4; j++) {
      37             int dx = a + dir[j][0], dy = b + dir[j][1];
      38             if(border(dx, dy) && c < mp[dx][dy]) mp[dx][dy] = c;
      39         }
      40     }
      41 }
      42 void bfs(int &ans)
      43 {
      44     queue<node> q; node rec;
      45     q.push(rec);
      46     if(mp[0][0] == 0) return;
      47     bool inq[maxn][maxn]; memset(inq, 0, sizeof(inq)); inq[0][0] = 1;
      48     while(!q.empty()) {
      49         rec = q.front(); q.pop();
      50         if(mp[rec.x][rec.y] == INT_MAX) {ans = rec.t; return; }
      51         for(int i = 0; i < 4; i++) {
      52             node dn; dn.x = rec.x + dir[i][0]; dn.y = rec.y + dir[i][1]; dn.t = rec.t + 1;
      53             if(border(dn.x, dn.y) && mp[dn.x][dn.y] > dn.t && !inq[dn.x][dn.y]) {
      54                 q.push(dn);
      55                 inq[dn.x][dn.y] = 1;
      56             }
      57         }
      58     }
      59 }
      60 void work()
      61 {
      62     int ans = -1;
      63     init();
      64     bfs(ans);
      65     printf("%d\n", ans);
      66 }
      67 int main()
      68 {
      69     while(scanf("%d", &m) != EOF) work();
      70     return 0;
      71 }
      View Code

       

      posted on 2014-10-16 16:51  Pobo_biu  閱讀(244)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 亚洲一区二区偷拍精品| 久久夜色撩人国产综合av| 宽甸| 在线看国产精品三级在线| 国产伦码精品一区二区| 东方四虎在线观看av| 亚洲男女羞羞无遮挡久久丫| 国产精品一区二区不卡91| 高潮毛片无遮挡高清视频播放| 人妻中文字幕精品一页| 农村老熟女一区二区三区| 亚洲欧美日韩在线不卡| 久久国产乱子伦免费精品无码 | 最新亚洲人成网站在线影院| 国产无套内射又大又猛又粗又爽| 两个人的视频www免费| 蜜臀av一区二区国产精品| 国产激情精品一区二区三区| 狠狠v日韩v欧美v| 国产精品va在线观看h| 国产一区二区三区黄色片| 久久综合激情网| 亚洲无av中文字幕在线| 精品国产肉丝袜在线拍国语| 亚洲日韩乱码中文无码蜜桃| 中文www天堂| 久久国内精品自在自线91| 日韩av片无码一区二区不卡| 99久久亚洲综合精品成人网| 国产亚洲精品超碰热| 国产精品一二三区蜜臀av| caoporn免费视频公开| 97精品久久九九中文字幕| 亚洲人成网站77777在线观看| 国产精品久久久久无码网站| 大帝AV在线一区二区三区| 92精品国产自产在线观看481页| 亚洲の无码国产の无码步美| 亚洲qingse中文字幕久久| 老司机午夜精品视频资源| 久久天天躁狠狠躁夜夜av不卡|