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:给wa的同学一组数据In Reply To:Re:给wa的同学一组数据 Posted by:hnust01 at 2010-04-22 16:17:25 上面数据都过了,提交wrong ~!! #include<stdio.h> int r[105][2],w,h,n; char r1[105][10]; int solve(int ro,char d) { int z,i; if(d=='L') { ++r1[ro][0]; r1[ro][0]%=4; return -2; } else if(d=='R') { --r1[ro][0]; r1[ro][0]%=4; return -2; } else { if(r1[ro][0]%4==0) --r[ro][1]; else if(r1[ro][0]%4==1) ++r[ro][0]; else if(r1[ro][0]%4==2) ++r[ro][1]; else --r[ro][0]; } if(r[ro][0]<1 || r[ro][0]>w || r[ro][1]<1 || r[ro][1]>h) return -1; else { for(i=0;i<n;i++) if(i!=ro && r[ro][0]==r[i][0] && r[ro][1]==r[i][1]) return i; } return -2; } int main() { int c,m,i,j,s,ins[105][2]; char ins1[105][10]; scanf("%d",&c); while(c--) { scanf("%d%d%d%d",&w,&h,&n,&m); for(i=0;i<n;i++) { scanf("%d%d",&r[i][0],&r[i][1]); scanf("%s",&r1[i]); if(r1[i][0]=='S') r1[i][0]=100; else if(r1[i][0]=='E') r1[i][0]=101; else if(r1[i][0]=='N') r1[i][0]=102; else r1[i][0]=103; } for(i=0;i<m;i++) { scanf("%d",&ins[i][0]); scanf("%s",&ins1[i]); scanf("%d",&ins[i][1]); } for(i=0;i<m;i++) { for(j=0;j<ins[i][1];j++) { s=solve(ins[i][0]-1,ins1[i][0]); if(s==-2)//ok { continue; } else if(s==-1) { printf("Robot %d crashes into the wall\n",ins[i][0]); goto loop; } else { printf("Robot %d crashes into robot %d\n",ins[i][0],s+1); goto loop; } } } printf("OK\n"); loop: ; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator