• <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>

            superman

            聚精會神搞建設 一心一意謀發展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            ZOJ 1019 - Illusive Chase

            Posted on 2008-03-19 12:42 superman 閱讀(338) 評論(0)  編輯 收藏 引用 所屬分類: ZOJ
              1 /* Accepted 1019 C++ 00:00.04 852K */
              2 #include <iostream>
              3 
              4 using namespace std;
              5 
              6 int n, m, p;
              7 bool map[101][101];
              8 
              9 struct
             10 {
             11     int s, t;
             12     char direction;
             13 }trip[100];
             14 
             15 bool finish;
             16 
             17 void swap(int & a, int & b)
             18 {
             19     a = a ^ b;
             20     b = a ^ b;
             21     a = a ^ b;
             22 }
             23 
             24 inline bool canGo(int sx, int sy, int tx, int ty)
             25 {
             26     if(tx >= 1 && tx <= n && ty >= 1 && ty <= m);
             27     else
             28         return 0;
             29     if(sx > tx)
             30         swap(sx, tx);
             31     if(sy > ty)
             32         swap(sy, ty);
             33     for(int i = sx; i <= tx; i++)
             34         for(int j = sy; j <= ty; j++)
             35             if(map[i][j])
             36                 return 0;
             37     return 1;
             38 }
             39 
             40 void search(int x, int y, int k)
             41 {
             42     if(finish)
             43         return;
             44     if(k > p)
             45     {
             46         finish = 1;
             47         return;
             48     }
             49     if(trip[k].direction == 'U')
             50     {
             51         for(int i = trip[k].s; i <= trip[k].t; i++)
             52             if(canGo(x - 1, y, x - i, y))
             53                 search(x - i, y, k + 1);
             54         return;
             55     }
             56     if(trip[k].direction == 'D')
             57     {
             58         for(int i = trip[k].s; i <= trip[k].t; i++)
             59             if(canGo(x + 1, y, x + i, y))
             60                 search(x + i, y, k + 1);
             61         return;
             62     }
             63     if(trip[k].direction == 'L')
             64     {
             65         for(int j = trip[k].s; j <= trip[k].t; j++)
             66             if(canGo(x, y - 1, x, y - j))
             67                 search(x, y - j, k + 1);
             68         return;
             69     }
             70     if(trip[k].direction == 'R')
             71     {
             72         for(int j = trip[k].s; j <= trip[k].t; j++)
             73             if(canGo(x, y + 1, x, y + j))
             74                 search(x, y + j, k + 1);
             75         return;
             76     }
             77 }
             78 
             79 int main()
             80 {
             81     int N;
             82     int s, t;
             83     char direction;
             84     
             85     cin >> N;
             86     while(N--)
             87     {
             88         cin >> n >> m;
             89         for(int i = 1; i <= n; i++)
             90             for(int j = 1; j <= m; j++)
             91                 cin >> map[i][j];
             92         p = 0;
             93         while(1)
             94         {
             95             cin >> s >> t;
             96             if(s == 0 && t == 0)
             97                 break;
             98             p++;
             99             trip[p].s = s;
            100             trip[p].t = t;
            101             cin >> trip[p].direction;
            102         }
            103         int ans = 0;
            104         for(int i = 1; i <= n; i++)
            105             for(int j = 1; j <= m; j++)
            106                 if(map[i][j] == 0)
            107                 {
            108                     finish = 0;
            109                     search(i, j, 1);
            110                     ans += finish;
            111                 }
            112         cout << ans << endl;
            113     }
            114     
            115     return 0;
            116 }
            117 
            久久91精品国产91久久麻豆| 久久国产成人| 精品国产乱码久久久久久郑州公司 | 久久精品女人天堂AV麻| 久久久久这里只有精品| 亚洲va久久久噜噜噜久久| 99re久久精品国产首页2020| 国产午夜精品久久久久九九| 狠狠色丁香婷婷久久综合五月 | 少妇高潮惨叫久久久久久| 亚洲天堂久久精品| 一本色道久久综合狠狠躁| 国产精品亚洲美女久久久| 久久99精品久久只有精品| 亚洲国产成人精品91久久久| 国产精品久久久久9999| 久久人人爽人人爽人人爽| 精品99久久aaa一级毛片| 高清免费久久午夜精品| 久久久久久精品久久久久| 久久久不卡国产精品一区二区| 久久99国产综合精品| 亚洲av日韩精品久久久久久a| 伊人久久大香线蕉AV一区二区| 久久噜噜电影你懂的| 久久亚洲AV成人无码电影| 久久精品人妻中文系列| 中文字幕久久精品| 久久午夜福利电影| 久久久人妻精品无码一区| 日本久久久久久中文字幕| 久久福利青草精品资源站免费| 精品国产VA久久久久久久冰| 免费久久人人爽人人爽av| 久久毛片一区二区| 99蜜桃臀久久久欧美精品网站| 亚洲国产成人精品女人久久久| 久久综合久久鬼色| 久久久午夜精品福利内容| 狠狠色婷婷久久一区二区| 乱亲女H秽乱长久久久|