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 |
Why RE????;;my code... Why RE??????? #include <stdio.h> int sr,sc,er,ec; int v[7][7]; int w[4][4]; int dir[4][2]={0,1,0,-1,1,0,-1,0}; int pth[7][7]; char answ[1000]; char cdir[5]="WENS"; inline int ccw(int x1,int y1,int x2,int y2,int x3,int y3){ return (((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))<0); } inline int cross(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){ x1<<=1; x2<<=1; y1<<=1; y2<<=1; x3<<=1; x3|=1; x4<<=1; x4|=1; y3<<=1; y3|=1; y4<<=1; y4|=1; if(ccw(x1,y1,x2,y2,x3,y3)^ccw(x1,y1,x2,y2,x4,y4)){ if(ccw(x3,y3,x4,y4,x1,y1)^ccw(x3,y3,x4,y4,x2,y2)){ return 1; } } return 0; } int main(){ int i,j,k,l,tj,tk; while(1){ scanf("%d%d",&sc,&sr); if(!sc && !sr)break; scanf("%d%d",&ec,&er); sc--,sr--,ec--,er--; for(i=0;i<6;i++){ for(j=0;j<6;j++){ v[i][j] = 0; } } for(i=0;i<3;i++){ scanf("%d%d%d%d",&w[i][1],&w[i][0],&w[i][3],&w[i][2]); } v[sr][sc]=1; for(i=0;i<6*6;i++){ for(j=0;j<6;j++){ for(k=0;k<6;k++){ if(v[j][k]){ for(l=0;l<4;l++){ if(dir[l][0]+j>=0&&dir[l][0]+j<6){ if(dir[l][1]+k>=0&&dir[l][1]+k<6){ if(cross(w[0][0],w[0][1],w[0][2],w[0][3],j,k,dir[l][0]+j,dir[l][1]+k))continue; if(cross(w[1][0],w[1][1],w[1][2],w[1][3],j,k,dir[l][0]+j,dir[l][1]+k))continue; if(cross(w[2][0],w[2][1],w[2][2],w[2][3],j,k,dir[l][0]+j,dir[l][1]+k))continue; if(v[dir[l][0]+j][dir[l][1]+k] == 0 || v[dir[l][0]+j][dir[l][1]+k] > v[j][k]+1){ v[dir[l][0]+j][dir[l][1]+k] = v[j][k]+1; pth[dir[l][0]+j][dir[l][1]+k] = l^1; } } } } } } } } answ[v[er][ec]-1]=0; i=v[er][ec]-2; j=er; k=ec; while(er!=sr || ec!=sc){ tj=j+dir[pth[j][k]][0]; tk=k+dir[pth[j][k]][1]; answ[i] = cdir[pth[j][k]]; j=tj; k=tk; i--; } printf("%s\n",answ); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator