Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:哪错了,帮下忙,谢谢!!!!

Posted by yxt008 at 2009-09-01 19:35:40 on Problem 1708
In Reply To:哪错了,帮下忙,谢谢!!!! Posted by:yxt008 at 2009-09-01 09:58:31
> #include<stdio.h>
> #include<string.h>
> #include<malloc.h>
> #include<stdlib.h>
> 
> int circles[101];
> int Aj[10001],Bj[10001],Cj[10001];
> int mark[150][150]={0};
> 
> struct room
> {
>        int Aj;
>        int Bj;
>        int flag;
>       struct room *next;
> };
>        
> 
> int Function(int N,int M,int L,int K,int Q)
> {
>         struct room *head,*p,*r;
>         int step=0,i,j,k;
>         
>         r=p=head=(struct room *)malloc(sizeof(struct room));
>         head->Aj=L;head->Bj=K;
>         head->flag=1;
>         head->next=NULL;
>         if(head->Aj==Q||head->Bj==Q)return(step);
>         
>         while(1)
>         {
>             if(head->flag==1)step++;
>             mark[head->Aj][head->Bj]=1;
>             mark[head->Bj][head->Aj]=1;
>             for(i=0;i<M;i++)
>             {
>                 if(head->Aj==Aj[i]&&Cj[i]==circles[head->Bj]&&head->Bj!=Bj[i]&&mark[Bj[i]][head->Bj]!=1&&mark[head->Bj][Bj[i]]!=1)
>                 {
>                       p=(struct room *)malloc(sizeof(struct room));
>                       p->Aj=Bj[i];p->Bj=head->Bj;
>                       p->flag=0;
>                       if(p->Aj==Q||p->Bj==Q)return(step);
>                       mark[p->Aj][p->Bj]=1;
>                       mark[p->Bj][p->Aj]=1;
>                       p->next=NULL;
>                       r->next=p;
>                       r=p;
>                 }
>                 if(head->Bj==Aj[i]&&Cj[i]==circles[head->Aj]&&head->Aj!=Bj[i]&&mark[Bj[i]][head->Aj]!=1&&mark[head->Aj][Bj[i]]!=1)
>                 {
>                       p=(struct room *)malloc(sizeof(struct room));
>                       p->Bj=Bj[i];p->Aj=head->Aj;
>                       p->flag=0;
>                       if(p->Aj==Q||p->Bj==Q)return(step);
>                       mark[p->Aj][p->Bj]=1;mark[p->Bj][p->Aj]=1;
>                       p->next=NULL;
>                       r->next=p;
>                       r=p;
>                 }
>             
>             }
>             if(head->flag==1)p->flag=1;    
>             head=head->next;
>             if(head==NULL)return(-1);
>                                                                                                                                   
>         }
> }
>                 
>                       
>                 
>             
> 
> int main()
> {
>     int N,L,K,Q,i,M,result;
>     scanf("%d %d %d %d",&N,&L,&K,&Q);
>     for(i=1;i<=N;i++)
>     {
>        scanf("%d",&circles[i]);
>     }
>     
>     scanf("%d",&M);
>     
>     for(i=0;i<M;i++)
>     {
>         scanf("%d %d %d",&Aj[i],&Bj[i],&Cj[i]);
>     }
>     
>     result=Function(N,M,L,K,Q);
>     if(result==-1)printf("NO\n");
>     else printf("YES\n%d\n",result);
>     system("pause");
>     return(0);
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator