| ||||||||||
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~#include<stdio.h> #include<string.h> typedef struct node { char name,str[28],color; }node; int d[26],q[100],top,front; void enq(int n) { top=(top+1)%100; q[(top-1)%100]=n; } int exq(void) { if((front+1)%100==top)return -1; front=(front+1)%100; return q[(front)%100]; } int main(void) { int n,i,j,max; node a[26]; while(scanf("%d",&n)!=EOF&&n!=0) { for(i=0;i<n;i++) { scanf("%s",a[i].str); a[i].color='w'; } front=0;top=1; a[0].color='g'; d[0]=1; enq(0); j=exq(); while(j!=-1) { for(i=2;i<strlen(a[j].str);i++) { if(a[a[j].str[i]-'A'].color=='w') { d[a[j].str[i]-'A']=1; a[a[j].str[i]-'A'].color='g'; } if(a[a[j].str[i]-'A'].color=='g'&&d[a[j].str[i]-'A']==d[j]) { d[a[j].str[i]-'A']++; enq(a[j].str[i]-'A'); } } a[j].color='b'; j=exq(); } for(i=0,max=0;i<n;i++) if(d[i]>max)max=d[i]; if(max==1) printf("%d channel needed.\n",max); else printf("%d channels needed.\n",max); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator