一道简单的拓扑排序,因为优先选小的所以用了优先队列
#include#include #include #include #include using namespace std;vector eg[505];int ans[505], ct[505];struct Node{ bool operator < (Node b)const { return va>b.va; } int va; Node(){} Node(int x){va=x;}} ;priority_queue q;int main(){ int i, j, n, m, now, a, b; while(scanf("%d%d",&n,&m)!=EOF) { now=0; memset(ct,0,sizeof(ct)); for(i=1;i<=n;i++) eg[i].clear(); for(i=0; i 0) printf(" "); printf("%d",ans[i]); } puts(""); } return 0;}