此题的本质问题就是对无向图的着色,使颜色使用最少的问题
#include#define maxn 27typedef struct Node{ int next[maxn]; int tot;}node;int main(){ int n; while(scanf("%d",&n)&&n!=0) { getchar();//吸收回车 node map[maxn]; int i,j,k; for(i=0;i mc) mc=color[i]; } if(mc==1) printf("1 channel needed.\n"); else printf("%d channels needed.\n",mc); } return 0;}