• <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
               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Section 2.4 - Tamworth Two

            Posted on 2009-04-23 10:54 superman 閱讀(111) 評論(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 
            久久r热这里有精品视频| 四虎国产精品成人免费久久| 久久精品天天中文字幕人妻| 国产精品久久国产精麻豆99网站| 香蕉久久一区二区不卡无毒影院| 久久久久亚洲爆乳少妇无| 中文国产成人精品久久亚洲精品AⅤ无码精品| 久久精品国产亚洲一区二区三区| 亚洲国产成人久久精品99| 人妻无码αv中文字幕久久| 91超碰碰碰碰久久久久久综合| 狠狠色伊人久久精品综合网| 人妻久久久一区二区三区| 99久久国产综合精品五月天喷水| 国产一区二区久久久| 久久久久久久尹人综合网亚洲| 亚洲精品99久久久久中文字幕 | 久久免费视频观看| 免费观看成人久久网免费观看| 麻豆久久久9性大片| 国内精品伊人久久久久| 亚洲国产婷婷香蕉久久久久久| 久久精品国产影库免费看| 久久精品国产2020| 国产精品99精品久久免费| 久久久久亚洲AV成人网人人网站| 91精品国产91久久久久久| 久久精品免费一区二区| 久久精品国产福利国产琪琪| 99久久人妻无码精品系列蜜桃| 久久婷婷五月综合国产尤物app | 久久久无码精品亚洲日韩按摩 | 久久久久国产日韩精品网站| 狠狠干狠狠久久| 99久久人妻无码精品系列蜜桃| 午夜天堂精品久久久久| 久久久久久精品免费看SSS| 久久久久免费精品国产| 久久乐国产综合亚洲精品| 亚洲欧美日韩精品久久亚洲区| 一本色道久久88综合日韩精品|