H题


先给出每条边的费用, q q q组询问,问当每条边的流量为 u / v u/v u/v时,跑到流量为1的最小费用
看到数据范围就知道肯定最多只能跑一次费用流,不然会直接 T T T飞
思路:求最小费用流的过程中记录每一次增广路增加的流和费用,用 m a p map map记录,最后贪心选择费用小的边进行输出(官方题解和一般的题解我一个都看不懂)
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=0x3f3f3f3f,maxn=2e5+10,maxm=10005;
struct edge{
int nex,v,cost,flow;
}e[maxm];
int head[maxn],cnt=1;
int n,m;
map<long long,long long>mp;
inline void add_edge(int u,int v,int cost,int flow){
int ww=head[u];
e[++cnt]={
ww,v,cost,flow};
head

1105

被折叠的 条评论
为什么被折叠?



