青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

USACO Section 2.4 The Tamworth Two

The Tamworth Two

BIO '98 - Richard Forster

A pair of cows is loose somewhere in the forest. Farmer John is lending his expertise to their capture. Your task is to model their behavior.

The chase takes place on a 10 by 10 planar grid. Squares can be empty or they can contain:

  • an obstacle,
  • the cows (who always travel together), or
  • Farmer John.

The cows and Farmer John can occupy the same square (when they `meet') but neither the cows nor Farmer John can share a square with an obstacle.

Each square is
represented
as follows:

  • . Empty square
  • * Obstacle
  • C Cows
  • F Farmer
Here is a sample grid:
            *...*.....
            ......*...
            ...*...*..
            ..........
            ...*.F....
            *.....*...
            ...*......
            ..C......*
            ...*.*....
            .*.*......
            

The cows wander around the grid in a fixed way. Each minute, they either move forward or rotate. Normally, they move one square in the direction they are facing. If there is an obstacle in the way or they would leave the board by walking `forward', then they spend the entire minute rotating 90 degrees clockwise.

Farmer John, wise in the ways of cows, moves in exactly the same way.

The farmer and the cows can be considered to move simultaneously during each minute. If the farmer and the cows pass each other while moving, they are not considered to have met. The chase ends when Farmer John and the cows occupy the same square at the end of a minute.

Read a ten-line grid that represents the initial state of the cows, Farmer John, and obstacles. Each of the ten lines contains exactly ten characters using the coding above. There is guaranteed to be only one farmer and one pair of cows. The cows and Farmer John will not initially be on the same square.

Calculate the number of minutes until the cows and Farmer John meet. Assume both the cows and farmer begin the simulation facing in the `north' direction. Print 0 if they will never meet.

PROGRAM NAME: ttwo

INPUT FORMAT

Lines 1-10: Ten lines of ten characters each, as explained above

SAMPLE INPUT (file ttwo.in)

*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......

OUTPUT FORMAT

A single line with the integer number of minutes until Farmer John and the cows meet. Print 0 if they will never meet.

SAMPLE OUTPUT (file ttwo.out)

49
Analysis
A simulating problem. These problems aims to replay actions by programs. Moreover, the total number of situations is 160000, which is used to make sure whether these two will never meet.
Code
/*
ID: braytay1
PROG: ttwo
LANG: C++
*/

#include 
<iostream>
#include 
<fstream>
using namespace std;

char map[10][10];
struct cows{
    
int x;
    
int y;
    
int face;
}
cow,farmer;
bool in(int x,int y){
    
if (x<0||x>=10return false;
    
if (y<0||y>=10return false;
    
else return true;
}

int main(){
    ifstream fin(
"ttwo.in");
    ofstream fout(
"ttwo.out");
    
for (int i=0;i<10;i++){
        
for (int j=0;j<10;j++){
            fin
>>map[i][j];
        }

    }

    
int time=0,met=0,x,y;
    
for (int i=0;i<10;i++){
        
for (int j=0;j<10;j++){
            
if (map[i][j]=='C'{
                cow.x
=i;
                cow.y
=j;
                cow.face
=1;
                map[i][j]
='.';
            }

            
if (map[i][j]=='F'{
                farmer.x
=i;
                farmer.y
=j;
                farmer.face
=1;
                map[i][j]
='.';
            }

        }

    }

    
for (;time<=160000;time++){
        
if (cow.x==farmer.x&&cow.y==farmer.y){
            met
=1;
            fout
<<time<<endl;
            
return 0;
        }

        x
=cow.x;y=cow.y;
        
switch(cow.face){
            
case 1:if(map[x-1][y]=='.'&&in(x-1,y)){cow.x--;break;}
                   
else {
                       cow.face
=(cow.face+1)%4;
                       
break;
                   }

            
case 2:if(map[x][y+1]=='.'&&in(x,y+1)){cow.y++;break;}
                   
else {
                       cow.face
=(cow.face+1)%4;
                       
break;
                   }

            
case 3:if(map[x+1][y]=='.'&&in(x+1,y)){cow.x++;break;}
                   
else {
                       cow.face
=(cow.face+1)%4;
                       
break;
                   }

            
case 0:if(map[x][y-1]=='.'&&in(x,y-1)){cow.y--;break;}
                   
else {
                       cow.face
=(cow.face+1)%4;
                       
break;
                   }

        }

        x
=farmer.x;y=farmer.y;
        
switch(farmer.face){
            
case 1:if(map[x-1][y]=='.'&&in(x-1,y)){farmer.x--;break;}
                   
else {
                       farmer.face
=(farmer.face+1)%4;
                       
break;
                   }

            
case 2:if(map[x][y+1]=='.'&&in(x,y+1)){farmer.y++;break;}
                   
else {
                       farmer.face
=(farmer.face+1)%4;
                       
break;
                   }

            
case 3:if(map[x+1][y]=='.'&&in(x+1,y)){farmer.x++;break;}
                   
else {
                       farmer.face
=(farmer.face+1)%4;
                       
break;
                   }

            
case 0:if(map[x][y-1]=='.'&&in(x,y-1)){farmer.y--;break;}
                   
else {
                       farmer.face
=(farmer.face+1)%4;
                       
break;
                   }

        }

    }

    
if (met==0) fout<<0<<endl;
    
return 0;
}

posted on 2008-08-13 20:59 幻浪天空領主 閱讀(272) 評論(0)  編輯 收藏 引用 所屬分類: USACO

<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

導航

統計

常用鏈接

留言簿(1)

隨筆檔案(2)

文章分類(23)

文章檔案(22)

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产美女搞久久| 欧美日韩精品一区二区| 国产精品高清一区二区三区| 一区二区欧美在线| 亚洲精品国产拍免费91在线| 欧美xxx成人| 国产精品99久久久久久白浆小说 | 久久精品女人| 欧美一区激情| 亚洲国产精品一区| 日韩亚洲精品电影| 国产精品国产自产拍高清av| 欧美一区二区三区四区在线观看| 亚洲欧美日韩国产综合精品二区| 国产一区二区三区在线观看免费视频| 久久久亚洲午夜电影| 久久影院午夜论| 亚洲免费av网站| 亚洲影院一区| 亚洲国产精品ⅴa在线观看| 91久久中文| 国产日本亚洲高清| 欧美成人精精品一区二区频| 欧美久久影院| 欧美在线播放一区| 麻豆精品视频在线| 亚洲免费视频在线观看| 久久一区中文字幕| 亚洲欧美精品伊人久久| 玖玖综合伊人| 午夜免费日韩视频| 欧美大片一区二区三区| 欧美一区二区免费视频| 蜜桃精品一区二区三区| 小黄鸭视频精品导航| 猛干欧美女孩| 久久久久国产精品午夜一区| 欧美人与性动交α欧美精品济南到| 欧美一区二区三区免费看| 欧美α欧美αv大片| 久久av一区| 欧美网站在线观看| 欧美福利在线观看| 国产一区二区三区在线免费观看 | 亚洲欧美美女| 亚洲免费观看高清在线观看| 欧美一级视频| 亚洲一级高清| 欧美激情精品久久久久久变态| 久久精品国产视频| 欧美三级欧美一级| 亚洲日韩欧美一区二区在线| 在线观看欧美一区| 午夜精品福利一区二区三区av| av成人毛片| 欧美不卡福利| 亚洲第一精品久久忘忧草社区| 韩国成人福利片在线播放| 99在线精品观看| 亚洲美女一区| 欧美精品18+| 欧美二区在线| 亚洲国产日韩欧美在线图片| 久久激情五月丁香伊人| 久久久久国产免费免费| 国产欧美日韩精品丝袜高跟鞋| 一本大道av伊人久久综合| 亚洲午夜av电影| 国产精品igao视频网网址不卡日韩| 亚洲激情在线视频| 99re在线精品| 欧美视频在线观看视频极品 | 欧美在线影院| 国产欧美日韩综合一区在线播放| 在线中文字幕一区| 欧美一区二区三区四区在线观看| 国产精品美女主播在线观看纯欲| 亚洲一区二区黄| 欧美在线一二三四区| 国产综合色在线| 久久久久88色偷偷免费| 欧美a级理论片| 亚洲美女免费精品视频在线观看| 欧美国产视频一区二区| 99精品国产99久久久久久福利| 宅男噜噜噜66一区二区| 国产精品免费福利| 久久精品毛片| 亚洲人成在线免费观看| 亚洲男女毛片无遮挡| 国产日韩av高清| 老妇喷水一区二区三区| 亚洲精品视频在线播放| 小嫩嫩精品导航| 亚洲国产高清视频| 欧美日韩国产影院| 亚洲欧美日韩爽爽影院| 欧美jizz19hd性欧美| 日韩视频永久免费| 国产精品久久999| 久久欧美中文字幕| aaa亚洲精品一二三区| 久久精品国产免费| 亚洲最新合集| 国产一区二区日韩精品欧美精品| 免费成人高清视频| 亚洲综合国产精品| 欧美激情在线播放| 久久国产一区二区三区| 亚洲精品123区| 国产欧美精品| 欧美日韩一区二区视频在线| 欧美在线二区| 在线亚洲国产精品网站| 欧美成人精品一区二区三区| 亚洲一区二区三区精品在线观看| 在线观看视频一区二区欧美日韩| 欧美日韩一区二区视频在线观看| 久久精品国产在热久久| 一区二区三区波多野结衣在线观看| 狼人天天伊人久久| 欧美一级视频| 亚洲一区二区在线| 99精品视频免费在线观看| 国产自产女人91一区在线观看| 欧美日韩国产一区精品一区| 美国十次了思思久久精品导航| 亚洲性夜色噜噜噜7777| 亚洲国产成人精品女人久久久| 巨胸喷奶水www久久久免费动漫| 亚洲欧美日韩国产综合| 夜夜嗨av一区二区三区| 亚洲国产专区校园欧美| 激情综合网址| 国内外成人免费激情在线视频网站 | 最新中文字幕一区二区三区| 国产九色精品成人porny| 欧美日韩视频免费播放| 久久久久久久性| 欧美一区二区三区四区高清| 亚洲一区二区三| 一区二区三区欧美视频| 一本色道久久综合| 亚洲久久成人| 一本久久a久久精品亚洲| 亚洲日本视频| 日韩一区二区高清| 日韩视频在线观看免费| 亚洲国产裸拍裸体视频在线观看乱了| 男男成人高潮片免费网站| 久久综合九色九九| 免费不卡亚洲欧美| 欧美大片国产精品| 亚洲国产精品激情在线观看 | 在线一区二区日韩| 中文一区字幕| 亚洲字幕一区二区| 午夜精品区一区二区三| 午夜欧美不卡精品aaaaa| 欧美一区二区视频在线观看2020| 香蕉成人伊视频在线观看| 久久av免费一区| 久久嫩草精品久久久精品| 久久亚洲一区| 欧美黄色一区| 一区二区三区**美女毛片 | 久久精品论坛| 欧美xx69| 99国产一区| 午夜精品三级视频福利| 久久精品国产久精国产一老狼| 久久久www| 欧美日韩大片| 国产色爱av资源综合区| 亚洲第一网站免费视频| 日韩一级在线| 久久激情中文| 91久久久久久国产精品| 亚洲综合精品四区| 老色鬼久久亚洲一区二区| 欧美日韩国产区| 国语自产精品视频在线看| 亚洲精品国产品国语在线app| 亚洲午夜极品| 久久久久久久一区| 亚洲精品在线视频观看| 欧美一区二区在线| 欧美国产日韩精品免费观看| 国产精品亚洲综合天堂夜夜| 亚洲电影免费观看高清完整版| 中日韩美女免费视频网站在线观看| 欧美一区国产在线| 亚洲国产导航| 久久精品二区三区| 国产精品国产a| 亚洲另类视频| 巨乳诱惑日韩免费av| 亚洲五月婷婷| 欧美极品在线播放| 精品成人一区二区|