|
|
back to boardwhy i got WA??????????????????Can you help me? Posted by arthur 25 Aug 2003 15:51 COde is here: #include "stdio.h" long x[1000],y[1000]; int que[1000],pare[1000],path[1000],c[1000]; int main() { int n,i,j,curret,count,temp,address;
scanf("%d",&n);
for(i=1;i<=n;i++) { c[i]=0; scanf("%ld%ld",&x[i],&y[i]); } scanf("%ld%ld%ld",&address,&x[0],&y[0]); que[0]=0; curret=0; count=1; while(curret<count) { if(x[que[curret]]==address||y[que[curret]]==address) break; for(i=1;i<=n;i++) { if(c[i]==0) { if((x[i]==x[que[curret]])||(x[i]==y [que[curret]])) { que[count]=i; pare[i]=que[curret]; c[i]=1; count++; } } } curret++; } if(x[que[curret]]==address||y[que[curret]]==address) { count=0; temp=que[curret]; while(1) { if(temp==0) break; count++; path[count]=temp; temp=pare[temp]; } printf("%ld\n",count); for(j=count;j>=1;j--) { printf("%d\n",path[j]); } } else printf("IMPOSSIBLE\n"); return 0; } |
|
|