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

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

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

      思路:

      將邊當作點,這樣建墻的時候點的坐標變換成x' = 2*x-1, y' = 2*y-1,t' = 2*t,  建門同理,但是因為門只要開一格就行所以t還是1。nemo的位置變換后是下取整x,y坐標各+1,

      然后 1代表墻,2代表門,4代表nemo。這題坑在nemo的范圍不知道,所以不能直接在開的建圖的數(shù)組里找,我就這樣RE了好多次,不在圖的范圍里的直接可以判斷輸出0。然后用優(yōu)先隊列存經(jīng)過的點,按經(jīng)過的門次數(shù)升序排序。

        1 #include <iostream>
        2 #include <cstdio>
        3 #include <queue>
        4 #include <vector>
        5 #include <cmath>
        6 #include <cstring>
        7 #include <string>
        8 #include <algorithm>
        9 using namespace std;
       10 
       11 int arr[500][500], minStep;
       12 bool vis[500][500];
       13 int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
       14 struct node
       15 {
       16     int x, y,step;
       17     node(){
       18         x = y = step = 0;
       19     }
       20     bool operator == (node that){
       21         if(that.x == x && that.y == y) return true;
       22         return false;
       23     }
       24     bool operator < (const node &that) const
       25     {
       26         return step > that.step;
       27     }
       28 };
       29 
       30 void init()
       31 {
       32     memset(arr, 0, sizeof(arr));
       33     memset(vis, 0, sizeof(vis));
       34     minStep = 160000;
       35 }
       36 void build_wall(int xx, int yy, int dd, int tt)
       37 {
       38     int x = 2*xx-1, y = 2*yy-1;
       39     if(dd)
       40         for(int i = y; i <= y+2*tt; i++)
       41             arr[x][i] = 1;
       42     else
       43         for(int i = x; i <= x+2*tt; i++)
       44             arr[i][y] = 1;
       45 }
       46 void door(int xx, int yy, int dd)
       47 {
       48     int x = 2 * xx -1, y = 2 * yy -1;
       49     if(dd) arr[x][y+1] = 2;
       50     else arr[x+1][y] = 2;
       51 }
       52 bool checkBound(int x, int y)
       53 {
       54     if(x < 0||y < 0||x>400||y>400) return false;
       55     return true;
       56 }
       57 void findNemo()
       58 {
       59     node nd, nd2;
       60     vis[0][0] = 1;
       61     priority_queue<node> q;
       62     q.push(nd);
       63     while(!q.empty()){
       64         nd = q.top(); q.pop();
       65         for(int i = 0; i < 4; i++) {
       66             int x = dir[i][0] + nd.x, y = dir[i][1] + nd.y;
       67             if(checkBound(x, y) && arr[x][y] != 1 && !vis[x][y]) {
       68                 nd2.step = nd.step; nd2.x = x; nd2.y = y;
       69                 vis[x][y] = 1;
       70                 if(arr[x][y] == 2) nd2.step++;
       71                 q.push(nd2);
       72                 if(arr[x][y] == 4) {
       73                     vis[x][y] = 0;
       74                     minStep = nd2.step;
       75                     return;
       76                 }
       77             }
       78         }
       79     }
       80 }
       81 void solve()
       82 {
       83     int n, m;
       84     while(scanf("%d%d", &m, &n) == 2 && n != -1 && m != -1) {
       85         init();
       86         int x, y, d, t;
       87         for(int i = 0; i < m; i++){
       88             scanf("%d%d%d%d", &x, &y, &d, &t);
       89             build_wall(x, y, d, t);
       90         }
       91 
       92         for(int i = 0; i < n; i++){
       93             scanf("%d%d%d", &x, &y, &d);
       94             door(x, y, d);
       95         }
       96         double f1, f2;
       97         scanf("%lf%lf", &f1, &f2);
       98         node nd; nd.x = 2*(int)floor(f1); nd.y = 2*(int)floor(f2);
       99         if(checkBound(nd.x, nd.y)){
      100             arr[nd.x][nd.y] = 4;
      101             findNemo();
      102             if(minStep == 160000) printf("-1\n");
      103             else printf("%d\n", minStep);
      104         }
      105         else printf("0\n");
      106     }
      107 }
      108 int main()
      109 {
      110     solve();
      111     return 0;
      112 }
      View Code

       

      posted on 2016-03-08 22:07  Pobo_biu  閱讀(294)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 色综合色综合色综合久久| 万安县| 少妇性bbb搡bbb爽爽爽欧美| 亚洲的天堂在线中文字幕| 亚洲日韩国产精品第一页一区| 巨熟乳波霸若妻在线播放| 亚洲av伦理一区二区| 国内精品久久人妻无码不卡| 亚洲一二三区精品美妇| 国产成人午夜在线视频极速观看| 国产精品美女久久久久久麻豆| 亚洲中文字幕aⅴ天堂| 亚洲激情国产一区二区三区| 中文字幕精品亚洲二区| 鄯善县| 无码人妻丰满熟妇区毛片| 亚洲这里只有久热精品伊人| 六月丁香婷婷色狠狠久久| 亚洲成人av免费一区| 中文字幕日韩一区二区三区不卡 | 日韩国产精品中文字幕| 国产精品国产三级国产试看| 人人爽天天碰天天躁夜夜躁| 国产日韩一区二区四季| 国产一区二区三区乱码| 国产SM重味一区二区三区| 国产伦精品一区二区三区妓女| 日韩有码精品中文字幕| 国产福利微视频一区二区| 中文字幕不卡在线播放| 欧美亚洲另类自拍偷在线拍| 扒开双腿猛进入喷水高潮叫声| 影音先锋亚洲成aⅴ人在| 国产综合色在线精品| 伊人成伊人成综合网222| 亚洲精品中文av在线| 国产精品白浆免费视频| 最近高清中文在线字幕在线观看| 无码伊人久久大杳蕉中文无码| 偷拍一区二区三区在线视频 | 株洲县|