Link:
#include <stdio.h>int main(){ puts("转载请注明出处[vmurder]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/45365831");}
Exercises
Put all the points into the priority queue of 0, each take out the largest mark, and the point is taken away after the point of 0 into the priority queue, the final reverse order output.
Code:
#include <queue>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 101000#define M 101000using namespace STD;structeli{intV,next;} E[M];intHead[n],cnt,d[n];inline voidAddintUintV) {d[v]++; E[++cnt].v=v; E[cnt].next=head[u]; head[u]=cnt;} priority_queue<int>q;intAns[n],n,m;intMain () {Freopen ("Test.in","R", stdin);intI,j,k;intA,b,c;intG for(scanf("%d", &g); g--;) {memset(Head,0,sizeofHead);memset(d,0,sizeofD);scanf("%d%d", &n,&m); Cnt=0; while(m--) {scanf("%d%d", &a,&b); Add (B,a); } m=0; for(i=1; i<=n;i++)if(!d[i]) Q.push (i); while(!q.empty ()) {ans[++m]=q.top (), Q.pop (); for(I=head[ans[m]];i;i=e[i].next)if(!--D[E[I].V]) Q.push (E[I].V); }if(m!=n)puts("impossible!");Else{ while(m)printf("%d", ans[m--]);puts("");} }}
"BZOJ4010" "HNOI2015" dish making