网络流-最大流
tomjobs
别慌,慌也没用
展开
-
2018ICPC南京 Problem I. Magic Potion(最大流)
题意:nnn个人,每个人有一个列表,可以杀掉列表里面的一只怪兽,每只怪兽只能死一次。有kkk瓶药水,可以让一个人多杀一只怪兽。求最多可以杀多少只怪兽。思路:最大流裸题,只是再熟悉一下板子。#include <cstdio>#include <cstring>#include <algorithm>#include <map>#include <cmath>#include <unordered_map>#inc.原创 2021-01-18 14:44:20 · 203 阅读 · 0 评论 -
AtCoder Regular Contest 107 F - Sum of Abs(最小割)
题意:一个图,删掉一个点的代价是a[i]a[i]a[i],一个连通块的价值为abs(∑b[i])abs(∑b[i])abs(∑b[i])。求通过删点能得到的最大价值。思路:参考博客:https://blog.csdn.net/ezoihqm/article/details/109411807感觉建图很巧妙的一道网络流。将一个点拆成取正值(+1),取反值(-1),删掉。那么建图就是 s−>i−>i+n−>ts->i->i+n->ts−>i−>i+.原创 2020-11-14 21:15:09 · 188 阅读 · 0 评论 -
D - Seat Assignment ZOJ - 3997(最大流)
题意:有10种人,第iii种人只想做到iii倍数编号座位上。每种人有a[i]a[i]a[i]个。一共有mmm个座位,求最多让多少个人坐座位。思路:一个数可以是1~10中多个数的倍数,所以如果你优先放iii的倍数,那么还可能会影响其他数的倍数。这就得去重。先找出1~10中任意数字组成的公倍数,去重后剩下48个。假设第iii个数字是num[i]num[i]num[i],则num[i]num[i]num[i]的数目为cnt[i]=mnum[i]cnt[i]=\frac{m}{num[i]}cnt[i]=原创 2020-10-14 20:30:34 · 206 阅读 · 0 评论 -
2020杭电多校第四场 Go Running(网络流,二分图匹配)
Problem DescriptionZhang3 is the class leader. Recently she’s implementing a policy about long-distance running. This forces every student in her class to take a run.There is a main road in the school from west to east, which can be regarded as an infini原创 2020-08-06 00:01:13 · 380 阅读 · 0 评论 -
Dining POJ - 3281(dinic最大流)
Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others.Farmer John has cooked fabulous meals for his cows, but he forgot to check his menu against their preferences. Although he might not be ab原创 2020-07-13 18:41:19 · 256 阅读 · 0 评论 -
P3376 【模板】网络最大流(dinic模板)
因为牛客第一场,被迫学习网络流。#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<vector>#include<queue>using namespace std;typedef long long ll;const int inf = 1 << 29, N = 50010, M = 300010;原创 2020-07-13 16:38:34 · 269 阅读 · 1 评论