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

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

            ZOJ 2803 - Crashing Robots

            Posted on 2008-05-26 10:41 superman 閱讀(258) 評論(0)  編輯 收藏 引用 所屬分類: ZOJ
             1 /* Accepted 2803 C++ 00:00.02 880K */
             2 #include <iostream>
             3 
             4 using namespace std;
             5 
             6 int main()
             7 {
             8     int N;
             9     cin >> N;
            10     while(N--)
            11     {
            12         int a, b, n, m;
            13         
            14         int px[101];
            15         int py[101];
            16         int dir[101];
            17         
            18         int map[101][101= { 0 };
            19         
            20         cin >> a >> b >> n >> m;
            21         for(int i = 1; i <= n; i++)
            22         {
            23             char c;
            24             cin >> px[i] >> py[i] >> c;
            25             map[px[i]][py[i]] = i;
            26             switch(c)
            27             {
            28                 case 'N' : dir[i] = 0break;
            29                 case 'E' : dir[i] = 1break;
            30                 case 'S' : dir[i] = 2break;
            31                 case 'W' : dir[i] = 3break;
            32             }
            33         }
            34         
            35         bool ok = true;
            36         for(int i = 0; i < m; i++)
            37         {
            38             int robot; char action; int repeat;
            39             
            40             cin >> robot >> action >> repeat;
            41          
            42             if(ok == false)
            43                 continue;
            44             
            45             if(action == 'L' || action == 'R')
            46             {
            47                 repeat %= 4;
            48                 if(action == 'L')
            49                     dir[robot] = (dir[robot] - repeat + 4% 4;
            50                 if(action == 'R')
            51                     dir[robot] = (dir[robot] + repeat) % 4;
            52                 continue;
            53             }
            54             //action == 'F'
            55             while(repeat--)
            56             {
            57                 int x = px[robot];
            58                 int y = py[robot];
            59                 
            60                 map[x][y] = 0;
            61                 switch(dir[robot])
            62                 {
            63                     case 0 : y++break;
            64                     case 1 : x++break;
            65                     case 2 : y--break;
            66                     case 3 : x--break;
            67                 }
            68                 if(map[x][y])
            69                 {
            70                     cout << "Robot " << robot
            71                          << " crashes into robot " << map[x][y] << endl;
            72                     break;
            73                 }
            74                 if(x == 0 || x == a + 1 || y == 0 || y == b + 1)
            75                 {
            76                     cout << "Robot " << robot << " crashes into the wall" << endl;
            77                     break;
            78                 }
            79                 px[robot] = x;
            80                 py[robot] = y;
            81                 map[x][y] = robot;
            82             }
            83             if(repeat != -1)
            84                 ok = false;
            85         }
            86         if(ok)
            87             cout << "OK" << endl;
            88     }
            89     
            90     return 0;
            91 }
            92 
            久久亚洲AV无码精品色午夜麻豆| 99久久99久久久精品齐齐| 国产精品女同一区二区久久| 草草久久久无码国产专区| 久久只有这里有精品4| 久久人妻少妇嫩草AV无码专区| 国产精品天天影视久久综合网| 久久精品国产亚洲Aⅴ蜜臀色欲| 欧美精品乱码99久久蜜桃| 久久综合久久综合久久综合| 久久久久亚洲精品天堂久久久久久| 久久这里只精品99re66| 久久夜色tv网站| 中文字幕久久波多野结衣av| 精品久久久久久99人妻| 久久精品国产亚洲av麻豆小说| 人人狠狠综合久久亚洲高清| 国产三级久久久精品麻豆三级 | 久久精品国产亚洲Aⅴ蜜臀色欲| 精品国产日韩久久亚洲| 99久久精品国产一区二区蜜芽 | 亚洲一区中文字幕久久| 人妻少妇久久中文字幕一区二区 | 久久精品夜夜夜夜夜久久| 亚洲精品99久久久久中文字幕 | 国产精品成人99久久久久| 亚洲狠狠婷婷综合久久蜜芽| 久久中文字幕视频、最近更新| 99久久无色码中文字幕| 午夜精品久久久久久毛片| 久久这里的只有是精品23| 久久久国产精品| 中文字幕成人精品久久不卡| 国产精品久久久天天影视| 97久久香蕉国产线看观看| 久久国产精品成人片免费| 色偷偷偷久久伊人大杳蕉| 欧洲精品久久久av无码电影| 亚洲中文字幕无码一久久区| 国内精品久久久久影院薰衣草 | 国产激情久久久久影院老熟女|