传送门:http://poj.org/problem?id=2947 Widget Factory Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 7109 Accepted: 2496 Description The widget factory produces several different kinds of widgets. Each widget is carefully built by a skill…
[洛谷P2921] [USACO08DEC]在农场万圣节Trick or Treat on the Farm 题目描述 每年,在威斯康星州,奶牛们都会穿上衣服,收集农夫约翰在N(1<=N<=100,000)个牛棚隔间中留下的糖果,以此来庆祝美国秋天的万圣节. 由于牛棚不太大,FJ通过指定奶牛必须遵循的穿越路线来确保奶牛的乐趣.为了实现这个让奶牛在牛棚里来回穿梭的方案,FJ在第i号隔间上张贴了一个"下一个隔间"Next_i(1<=Next_i<=N),告诉奶牛要去…
[模板整合计划]图论-有向无环图 (DAG) 与树 一:[拓扑排序] 最大食物链计数 \(\text{[P4017]}\) #include<cstring> #include<cstdio> #include<queue> #define Re register int using namespace std; const int N=5003,M=5e5+3,inf=2e9,P=80112002; int n,m,x,y,o,ans,dp[N],ru[N],chu[…