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 |
这个程序我写了一下,能实现题目的要求,为什么提交后就是“wrong answer”呢?请哪位大侠指教一下...#include<stdio.h> #include<math.h> int main() { int K,A,B,N,M,num,step; int a[10000][3]={0}; char c; scanf("%d",&K); while(K-->0){ scanf("%d%d",&A,&B); scanf("%d%d",&N,&M); for(int i=0;i<N;i++){ scanf("%d%d%c%c",&a[i][0],&a[i][1],&c,&c); switch(c){ case 'E':a[i][2]=1;break; case 'N':a[i][2]=2;break; case 'W':a[i][2]=3;break; case 'S':a[i][2]=4; } } for(int i=0;i<M;i++){ scanf("%d%c%c%d",&num,&c,&c,&step); switch(c){ case 'L': a[num-1][2]=(a[num-1][2]+step)%4;break; case'R': a[num-1][2]=abs((a[num-1][2]-step)%4);break; case 'F': for(int j=0;j<step;j++){ if(a[num-1][2]==1){a[num-1][0]=a[num-1][0]+1;} else if(a[num-1][2]==2){a[num-1][1]=a[num-1][1]+1;} else if(a[num-1][2]==3){a[num-1][0]=a[num-1][0]-1;} else{a[num-1][1]=a[num-1][1]-1;} for(int k=0;k<N;k++){ if(a[k][0]==a[num-1][0]&&a[k][1]==a[num-1][1]&&k!=num-1){ printf("Robot %d crashes into robot %d\n",num,k+1);num=i;goto mark; } } if(a[num-1][0]<1||a[num-1][0]>A||a[num-1][1]<1||a[num-1][1]>B){ printf("Robot %d crashes into the wall\n",num);num=i;goto mark; } } } } printf("OK\n"); goto mark1; mark:for(int i=num+1;i<M;i++){scanf("%d%c%c%d",&num,&c,&c,&step);} mark1: for(int i=0;i<N;i++){ for(int j=0;j<3;j++){a[i][j]=0;} } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator