拓扑排序
拓扑排序
# include <bits/stdc++.h>
using namespace std;
const int LEN_of_Node=1e4+100;
const int LEN_of_Edge=2e4+100;
int cnt;
int n,m;
int num;
struct Edge
{
    int to,next;
};
Edge edge[LEN_of_Edge];
int head[LEN_of_Node];//领接表存图
int father[LEN_of_Node];//并查集用
int in[LEN_of_Node];//记录入度
int a[LEN_of_Node];
char c[LEN_of_Node];
int b[LEN_of_Node];
void init()//初始化函数
{
    cnt=1;
    memset(in,0,sizeof(in));
    memset(head,0,sizeof(head));
    for(int i=1;i<=n;i++) father[i]=i;
}
int Find(int x)//并查集所用函数
{
    return x==father[x]?x:father[x]=Find(father[x]);
}
void join(int aa,int bb)//并查集合并函数
{
    int x=Find(aa);
    int y=Find(bb);
    if(x!=y){
        in[x]=-1;
        father[x]=y;
    }
}
void Add(int u,int v)//邻接表添加节点的函数
{
    edge[cnt].next=head[u];
    edge[cnt].to=v;
    head[u]=cnt++;
}
int Topo()//拓扑排序
{
    queue<int> que; //用队列记录
    for(int i=1;i<=n;i++){
        if(in[i]==0&&i==Find(i)) que.push(i);
    }
    int sign=0;
    while(! 
                    
                     
                    
                