神奇的样例错误。。。

P3243 [HNOI2015] 菜肴制作

``` #include<cstdio> #include<iostream> #include<vector> #include<queue> #include<cstring> using namespace std; const int MAXN=100100; vector<int>G[MAXN]; int n,x,y,a,b,in[MAXN],ans[MAXN]; struct cmp { bool operator()(int a,int b) { return a>b; } }; priority_queue<int,vector<int>,cmp>q; void topsort(int n) { int size=0,tot=0; for(int i=1;i<=n;i++) if(!in[i]) q.push(i); while(!q.empty()) { int v=q.top(),len=G[v].size(); q.pop(); tot++; ans[++size]=v; for(int i=0;i<len;i++) { int w=G[v][i]; in[w]--; if(!in[w]) q.push(w); } } if(tot==x) { for(int i=1;i<=size-1;i++) cout<<ans[i]<<" "; cout<<ans[size]<<endl; } else { cout<<"Impossible!"<<endl; } } int main() { cin>>n; for(int i=0;i<n;i++) { cin>>x>>y; for(int j=0;j<y;j++) { cin>>a>>b; in[b]++; G[a].push_back(b); } topsort(x); memset(in,0,sizeof(in)); memset(ans,0,sizeof(ans)); for(int i=1;i<=x;i++) G[i].clear(); while(!q.empty()) q.pop(); } } ```
by zhangjiacheng @ 2018-12-27 19:55:51


大佬您在呀%%%@[zhangjiacheng](/space/show?uid=25006)
by PRXOR @ 2018-12-27 19:59:25


@PRXOR。。。
by zhangjiacheng @ 2018-12-27 20:02:17


@[skip1978](/space/show?uid=155315) @[little_gift](/space/show?uid=22132) @[mrsrz](/space/show?uid=6813) 同机房的大佬看一下吧
by zhangjiacheng @ 2018-12-27 20:03:29


@[Memory_of_winter](/space/show?uid=22072) @[WengWeijie](/space/show?uid=87538)
by zhangjiacheng @ 2018-12-27 20:04:15


好吧我知道了。。。
by zhangjiacheng @ 2018-12-27 20:10:26


|