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

            聚精會(huì)神搞建設(shè) 一心一意謀發(fā)展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            Section 2.4 - Tamworth Two

            Posted on 2009-04-23 10:54 superman 閱讀(106) 評(píng)論(0)  編輯 收藏 引用 所屬分類: USACO
              1 #include <iostream>
              2 
              3 using namespace std;
              4 
              5 enum { N, E, S, W };
              6 
              7 struct Point
              8 {
              9     int x, y;
             10 
             11     const Point next(int dir)
             12     {
             13         Point nextP;
             14         switch (dir)
             15         {
             16             case N : nextP.x = x - 1, nextP.y = y; break;
             17             case E : nextP.x = x, nextP.y = y + 1break;
             18             case S : nextP.x = x + 1, nextP.y = y; break;
             19             case W : nextP.x = x, nextP.y = y - 1break;
             20         }
             21         return nextP;
             22     }
             23     bool operator == (const Point & p)
             24     {
             25         return x == p.x && y == p.y;
             26     }
             27 }   ;
             28 
             29 char map[10][10];
             30 
             31 bool inside(const Point & p)
             32 {
             33     return p.x >= 0 && p.x < 10 && p.y >= 0 && p.y < 10;
             34 }
             35 bool couldReach(const Point & p)
             36 {
             37     return map[p.x][p.y] == '.';
             38 }
             39 
             40 int main()
             41 {
             42     freopen("ttwo.in""r", stdin);
             43     freopen("ttwo.out""w", stdout);
             44 
             45     Point cowStartP, JohnStartP;
             46 
             47     for (int i = 0; i < 10; i++)
             48     for (int j = 0; j < 10; j++)
             49     {
             50         cin >> map[i][j];
             51 
             52         if (map[i][j] == 'C')
             53             cowStartP.x = i, cowStartP.y = j, map[i][j] = '.';
             54         if (map[i][j] == 'F')
             55             JohnStartP.x = i, JohnStartP.y = j, map[i][j] = '.';
             56     }
             57 
             58     int curTime = 0;
             59     int ReachTime[10][10][4][10][10][4];
             60 
             61     memset(ReachTime, 255sizeof(ReachTime));
             62 
             63     Point cowCurP = cowStartP, JohnCurP = JohnStartP;
             64     int cowCurDir = N, JohnCurDir = N;
             65 
             66     while (true)
             67     {
             68         if (cowCurP == JohnCurP)
             69         {
             70             cout << curTime << endl;
             71             return 0;
             72         }
             73 
             74         if (ReachTime[cowCurP.x][cowCurP.y][cowCurDir][JohnCurP.x][JohnCurP.y][JohnCurDir] != -1)
             75             break;
             76         else
             77             ReachTime[cowCurP.x][cowCurP.y][cowCurDir][JohnCurP.x][JohnCurP.y][JohnCurDir] = curTime;
             78 
             79         Point cowNextP, JohnNextP;
             80 
             81         cowNextP = cowCurP.next(cowCurDir);
             82         if (inside(cowNextP) && couldReach(cowNextP))
             83             cowCurP = cowNextP;
             84         else
             85             cowCurDir = (cowCurDir + 1% 4;
             86 
             87         JohnNextP = JohnCurP.next(JohnCurDir);
             88         if (inside(JohnNextP) && couldReach(JohnNextP))
             89             JohnCurP = JohnNextP;
             90         else
             91             JohnCurDir = (JohnCurDir + 1% 4;
             92 
             93         curTime++;
             94     }
             95 
             96     cout << 0 << endl;
             97 
             98     return 0;
             99 }
            100 
            久久综合给合久久国产免费 | 久久人人爽人人爽人人片AV不| 久久se精品一区二区| 久久亚洲私人国产精品| 国产成年无码久久久免费| 亚洲国产小视频精品久久久三级| 99热热久久这里只有精品68| 国产成人精品白浆久久69 | 国产精品久久久久久久人人看 | 久久ww精品w免费人成| 97久久国产综合精品女不卡| 久久中文字幕人妻熟av女| 亚洲综合日韩久久成人AV| 亚洲精品国产美女久久久| 日韩人妻无码一区二区三区久久| 青青草原精品99久久精品66| 久久天天躁狠狠躁夜夜avapp| 久久精品国产亚洲av水果派| 久久av无码专区亚洲av桃花岛| 国内精品久久久久| 精品久久久久久99人妻| 久久精品国产只有精品66 | 久久伊人影视| 久久婷婷是五月综合色狠狠| 日本久久久久亚洲中字幕| 色成年激情久久综合| 看全色黄大色大片免费久久久| 亚洲精品无码成人片久久| 麻豆精品久久精品色综合| 香港aa三级久久三级老师2021国产三级精品三级在 | 精品久久人妻av中文字幕| 99久久精品国产毛片| 综合久久精品色| jizzjizz国产精品久久| 理论片午午伦夜理片久久| 国产婷婷成人久久Av免费高清| 久久97久久97精品免视看| 中文国产成人精品久久不卡| 久久精品一区二区影院| 久久99国产综合精品| 波多野结衣久久精品|