# hiho1192 简单的树嵌入（构造题）

### 输入

n ≤ 100. 0 ≤ xi, yi ≤ n - 1.

### 输出

`30 11 2`

`20 01 01 1`

`#include<iostream>#include<stdio.h>#include<algorithm>#include<math.h>#include<queue>#include<string>#include<string.h>#include<stack>#include<vector>#include<set>#include<map>typedef long long LL;typedef unsigned long long LLU;double pi = acos(-1);const int nn = 110000;const int inf = 0x3fffffff;const int inff = 0x3fffffff;const LL mod = 1000000003;using namespace std;int n;struct node{    int en,next;}E[210];int p[110],num;int ans[110][110];int len[110];void init(){    memset(p,-1,sizeof(p));    num=0;}void add(int st,int en){    E[num].en=en;    E[num].next=p[st];    p[st]=num++;    E[num].en=st;    E[num].next=p[en];    p[en]=num++;}bool use[nn];queue<int>que;int main(){    int i,j;    while(scanf("%d",&n)!=EOF)    {        init();        int u,v;        for(i=1;i<n;i++)        {            scanf("%d%d",&u,&v);            add(u,v);        }        memset(ans,0,sizeof(ans));        memset(len,0,sizeof(len));        memset(use,false,sizeof(use));        use[0]=true;        len[0]=1;        que.push(0);        int cnt=1;        while(que.size())        {            int sta=que.front();            que.pop();            for(i=p[sta];i+1;i=E[i].next)            {                int w=E[i].en;                if(!use[w])                {                    use[w]=true;                    for(j=0;j<len[sta];j++)                    {                        ans[w][j]=ans[sta][j];                    }                    ans[w][cnt++]=1;                    len[w]=cnt;                    que.push(w);                }            }        }        printf("%d\n",cnt);        for(i=0;i<n;i++)        {            for(j=0;j<cnt;j++)            {                printf("%d%c",ans[i][j],j==cnt-1?'\n':' ');            }        }    }    return 0;}`

0 0