const int maxn = 500 + 10;
const int INF = 0x3fffffff;
//topogogicalsort
vector<int> adj[maxn];
int n, m, indegree[maxn];
bool topologicalsort() {
//1 初始化记录每个点入度的数组
int num_vertex = 0;
queue<int> q;
for (int i = 0; i < n; i++)
if (indegree[i] == 0)
q.push(i);
//2
while (!q.empty()) {
int u = q.front();
printf("%d", u);
q.pop();
//3
for (int i = 0; i < adj[u].size(); i++) {
int v = adj[u][i];
indegree[v]--;
if (indegree[v] == 0)
q.push(v);
}
//4
adj[u].clear();//清空u的所有出边
num_vertex++;
}
}