随笔分类 - 网络流 费用流
摘要:link #include <iostream> #include <vector> #include <algorithm> #include <unordered_set> #include <cstring> #include <queue> # define LL long long usi
阅读全文
摘要:link #include <iostream> #include <vector> #include <algorithm> #include <unordered_set> #include <cstring> #include <queue> # define LL long long usi
阅读全文
摘要:link Solution 1 : min cost flow Break each cell into two nodes i and i', connect i to i' (i+mn) with an edge with flow 1, cost 0. For each cell i, con
阅读全文
摘要:Link Solution 1 Hungarian: class Solution { public: int m,n; vector<vector<int>> g; vector<vector<int>> dir={{0,-1},{-1,-1},{1,-1},{0,1},{-1,1},{1,1}}
阅读全文
摘要:题目链接 解法参见:https://www.luogu.com.cn/blog/cicos/solution-p2774# Code: 1 #include <bits/stdc++.h> 2 #define LL long long 3 #define INF 0x3f3f3f3f; 4 usin
阅读全文
摘要:题目链接 解法: 首先考虑逆向思维,求最少要使用的士兵个数,转化为,初始的时候所有能放士兵的地方都放了士兵的情况下,最多能删掉多少个士兵。 1. 给每一行每一列分别建一个点,对于所有非障碍坐标(x,y),从x行对应的点 向 y列对应的点连一条容量为1的边,表示这个位置的士兵最多可以删除一次。 2.
阅读全文
摘要:题目链接 方法: 重点在建图!!!将一天拆成晚上和早上; 1. 从源点向每一天晚上连一条流量为当天所用餐巾x,费用为0的边; 2. 每一天早上向汇点连一条流量为当天所用餐巾x,费用为0的边; 3. 从每一天晚上向第二天晚上连一条流量为INF,费用为0的边,表示每天晚上可以将脏餐巾留到第二天晚上; 4
阅读全文
摘要:题目:P1559 https://www.luogu.com.cn/problem/P1559 羽毛球队有男女运动员各n人。给定2 个n×n矩阵P和Q。P[i][j]是男运动员i和女运动员j配对组成混合双打的男运动员竞赛优势;Q[i][j]是女运动员i和男运动员j配合的女运动员竞赛优势。由于技术配合
阅读全文