E. ALT http://codeforces.com/problemset/problem/786/E 题意: 给出一棵 n 个节点的树与 m 个工人.每个工人有一条上下班路线(简单路径),一个工人会得到满足只要下面一项满足:1.他得到一只puppy 2.他的上下班路径上每条边都有一只doge求使所有工人满足的最小dog数并输出方案.n≤20000,m≤10000 想法:暴力建图,源点连向工人Xi,边Yi连向汇点,容量为1.然后工人向其路径上的边连容量为1的边.O(nm) 优化建图:路径为树…
感觉和昨天写了的题一模一样... 这种题也能用hall定理取check, 感觉更最小割差不多. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pai…
原题地址:https://codeforces.com/contest/1082/problem/G G. Petya and Graph time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya has a simple graph (that is, a graph without loops or multiple e…