Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:跪求大牛们啊 !请告诉我那里错啦!!!!!!!!In Reply To:跪求大牛们啊 !请告诉我那你错啦!!!!!!!! Posted by:guangming1987 at 2008-11-30 09:26:10 > #include<iostream> > #include<string> > using namespace std; > struct robot{int x,y;char d;}p[101]; > int t[101][101]; > void force(int p,robot *b){ > if(b->d=='E')b->x+=p; > if(b->d=='W')b->x-=p; > if(b->d=='N')b->y+=p; > if(b->d=='S')b->y-=p; > } > int main(){ > int q1,q2,err,num,A,B,n,m,no,ti,i,j;bool flag;char ins; > cin>>num; > while(num--){ > flag=0;err=0; > cin>>A>>B; > cin>>n>>m; > memset(t,-1,sizeof(t)); > for(int i=1;i<=n;i++){cin>>p[i].x>>p[i].y>>p[i].d;t[p[i].x][p[i].y]=i;} > for(i=1;i<=m;i++){ > cin>>no>>ins>>ti; > if(flag==0){ > if(ins=='F'){ > t[p[no].x][p[no].y]=-1; > force(ti,&p[no]); > if(p[no].x<=0||p[no].x>A||p[no].y<=0||p[no].y>B){q1=no;err=1;flag=1; } > else if(t[p[no].x][p[no].y]!=-1){q1=no;q2=t[p[no].x][p[no].y];flag=1;err=2;} > t[p[no].x][p[no].y]=no; > } > else > for(j=0;j<ti%4;j++){ > if(ins=='L'){ > if(p[no].d=='E')p[no].d='N'; > else if(p[no].d=='N')p[no].d='W'; > else if(p[no].d=='W')p[no].d='S'; > else if(p[no].d=='S')p[no].d='E'; > } > if(ins=='R'){ > if(p[no].d=='E')p[no].d='S'; > else if(p[no].d=='S')p[no].d='W'; > else if(p[no].d=='W')p[no].d='N'; > else if(p[no].d=='N')p[no].d='E'; > } > } > > } > } > if(err==0)printf("OK\n"); > if(err==1&&flag==1)printf("Robot %d crashes into the wall\n",q1); > if(err==2&&flag==1)printf("Robot %d crashes into robot %d\n",q1,q2); > } > return 0; > } > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator