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 |
那位牛大哥帮我看下,小弟实在不知那里错了!!#include"iostream" using namespace std; struct Root { int r; int c; int direct; }root[101]; int main() { int Test_case; cin>>Test_case; while(Test_case--) { int a[101][101]; memset(a,0,sizeof(a)); int aa,b,root_num,ms_num,x,y,flag[101]={0},flag1=-2,f=0; char fx; cin>>aa>>b; cin>>root_num>>ms_num; for(int i=1;i<=root_num;i++) { cin>>x>>y>>fx; root[i].c=x; root[i].r=b-y+1; a[b-y+1][x]=i; if(fx=='E') root[i].direct=0; if(fx=='N') root[i].direct=1; if(fx=='W') root[i].direct=2; if(fx=='S') root[i].direct=3; } for(int j=1;j<=ms_num;j++) { int root_list,repeat,rr; char operat; cin>>root_list>>operat>>repeat; if(operat=='L') { root[root_list].direct=(root[root_list].direct+repeat)%4; } if(operat=='R') { root[root_list].direct=root[root_list].direct+(4-(repeat)%4); } if(operat=='F') { if(root[root_list].direct==0) { for(int rrr=1,rr=1;rr<=repeat;rr++) { a[root[root_list].r][root[root_list].c]=0; root[root_list].c=root[root_list].c+rrr; if(a[root[root_list].r][root[root_list].c]>0) { if(flag1==-2) { flag1=root_list; flag[flag1]=a[root[root_list].r][root[root_list].c]; f=1; break; } } else if(root[root_list].c>aa) { if(flag1==-2) { flag1=root_list; flag[flag1]=-1; f=1; break; } if(flag1!=-2) break; } } if(rr=repeat+1) { a[root[root_list].r][root[root_list].c]=root_list; } } else if(root[root_list].direct==1) { for(int rrr=1,rr=1;rr<=repeat;rr++) { a[root[root_list].r][root[root_list].c]=0; root[root_list].r=root[root_list].r-rrr; if(a[root[root_list].r][root[root_list].c]>0) { if(flag1==-2) { flag1=root_list; flag[flag1]=a[root[root_list].r][root[root_list].c]; f=1;break; } if(flag1!=-2) break; } else if(root[root_list].r<=0) { if(flag1==-2) { flag1=root_list; flag[flag1]=-1; f=1; break; } if(flag1!=-2) break; } } if(rr=repeat+1) { a[root[root_list].r][root[root_list].c]=root_list; } } else if(root[root_list].direct==2) { for(int rrr=1,rr=1;rr<=repeat;rr++) { a[root[root_list].r][root[root_list].c]=0; root[root_list].c=root[root_list].c-rrr; if(a[root[root_list].r][root[root_list].c]>0) { if(flag1==-2) { flag1=root_list; flag[flag1]=a[root[root_list].r][root[root_list].c]; f=1;break; } if(flag1!=-2) break; } else if(root[root_list].c<=0) { if(flag1==-2) { flag1=root_list; flag[flag1]=-1; f=1;break; } if(flag1!=-2) break; } } if(rr==repeat+1) { a[root[root_list].r][root[root_list].c]=root_list; } } else if(root[root_list].direct==3) { for(int rrr=1,rr=1;rr<=repeat;rr++) { a[root[root_list].r][root[root_list].c]=0; root[root_list].r=root[root_list].r+rrr; if(a[root[root_list].r][root[root_list].c]>0) { if(flag1==-2) { flag1=root_list; flag[flag1]=a[root[root_list].r][root[root_list].c]; f=1;break; } if(flag1!=-2) break; } else if(root[root_list].r>b) { if(flag1==-2) { flag1=root_list; flag[flag1]=-1; f=1; break; } if(flag1!=-2) break; } } if(rr==repeat+1) { a[root[root_list].r][root[root_list].c]=root_list; } } } } if(flag1==-2) cout<<"OK"<<endl; else { if(flag[flag1]==-1) cout<<"Robot "<<flag1<<" crashes into the wall "<<endl; else if(flag[flag1]>0) cout<<"Robot "<<flag1<<" crashes into robot "<<flag[flag1]<<endl; } } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator