文章
40
粉丝
512
获赞
13
访问
375.0k
#include<bits/stdc++.h>
using namespace std;
int const MAXN=501;
vector<vector<int> > graph(MAXN);
int degree[MAXN]={0};
vector<int> Topo(int n){
priority_queue<int,vector<int> ,greater<int> > node;
vector<int> ans;
for(int i=1;i<=n;i++){
if(degree[i]==0){
node.push(i);
}
}
while(!node.empty()){
int u=node.top();
node.pop();
ans.push_back(u);
for(int i=0;i<graph[u].size();i++){
int v=graph[u][i];
degree[v]--;
if(degree[v]==0){
node.push(v);
}
}
}
return ans;
}
int main(){
int n,m;
while(cin>>n>>m){
if(n==0&&m==0){
break;
}
while(m--){
int win,lose;
cin>>win>>lose;
graph[win].push_back(lose);
degree[lose]+...
登录后发布评论
错了哥