标签:its font max int com 16px char while head
topu序
//P1113 杂务 #include<bits/stdc++.h> using namespace std; inline int read(){ int k=0,f=1; char c=getchar(); while(!isdigit(c)){ if(c==‘-‘) f=-1; c=getchar(); } while(isdigit(c)){ k=(k<<1)+(k<<3)+(c^48); c=getchar(); } return k; } int n; struct cc{ int to,nxt/*,w*/; }g[10000005]; int W[10005],T[10005],head[10005<<1],len,in[10005],ans; inline void add(int u,int v/*,int w*/){ g[++len].to=v; // g[len].w=w; g[len].nxt=head[u]; head[u]=len; } inline void topu(){ queue<int> q; for(int i=1;i<=n;i++){ if(in[i]==0) q.push(i); } while(q.size()){ int t=0; int x=q.front();q.pop(); W[x]+=T[x]; ans=max(ans,W[x]); for(int i=head[x];i;i=g[i].nxt){ int y=g[i].to; W[y]=max(W[y],W[x]); in[y]--; if(in[y]==0) q.push(y); } } // topu(); } int main(){ n=read(); int tt,x; for(int y=1;y<=n;y++){ tt=read();T[y]=read(); while(1){ x=read(); if(x==0) break; add(x,y/*,tt*/); in[y]++; } } topu(); cout<<ans; return 0; }
标签:its font max int com 16px char while head
原文地址:https://www.cnblogs.com/duojiaming/p/11819099.html