博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[SDOI2011]工作安排
阅读量:4585 次
发布时间:2019-06-09

本文共 1263 字,大约阅读时间需要 4 分钟。

原题的话,由于保证了wi<wi+1,是一个比较simple的费用流啦。

如果不保证wi递增的话,也可以有一个比较暴力的复杂度和流量相关的做法。

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define N 220000#define M 220000#define L 200000#define eps 1e-7#define inf 1e9+7#define ll long longusing namespace std;inline int read(){ char ch=0; int x=0,flag=1; while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;} while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();} return x*flag;}struct edge{ int to,nxt,flow,w;}e[M];int num,head[N];inline void add(int x,int y,int w,int z){ e[++num]=(edge){y,head[x],w,+z};head[x]=num; e[++num]=(edge){x,head[y],0,-z};head[y]=num;}queue
q;bool in_queue[N];int s,t,T[N],W[N],dis[N],pre[N],last[N],flow[N];bool spfa(){ for(int i=0;i<=t;i++)dis[i]=flow[i]=inf; dis[s]=0;q.push(s);in_queue[s]=true; while(!q.empty()) { int x=q.front(); q.pop();in_queue[x]=false; for(int i=head[x];i!=-1;i=e[i].nxt) { int to=e[i].to; if(dis[to]>dis[x]+e[i].w&&e[i].flow) { dis[to]=dis[x]+e[i].w; flow[to]=min(flow[x],e[i].flow); pre[to]=x;last[to]=i; if(!in_queue[to])q.push(to),in_queue[to]=true; } } } return dis[t]

转载于:https://www.cnblogs.com/Creed-qwq/p/10082849.html

你可能感兴趣的文章
Jmeter参数化
查看>>
Linux用iso镜像制作本地yum源
查看>>
在SSH项目中Struts2、Spring、Hibernate分别起到什么作用?
查看>>
网络编程协议
查看>>
5.9
查看>>
备份项目实例
查看>>
8天学通MongoDB——第二天 细说增删查改
查看>>
TextBloc研究
查看>>
Engine auto idle help conserve fuel reduce noise
查看>>
MAC下安装pomelo
查看>>
182. Duplicate Emails
查看>>
Redis、Memcache和MongoDB的区别
查看>>
设计模式笔记 ------ 原型模式
查看>>
通过Repeater控件绑定数据,相同数据合并单元格。
查看>>
h5 和之前版本的区别
查看>>
【UVAlive 3989】 Ladies' Choice (稳定婚姻问题)
查看>>
【FFT&NTT 总结】
查看>>
洛谷——P1802 5倍经验日
查看>>
leetcode121—Best Time to Buy and Sell Stock
查看>>
【系统优化】为系统提速,何须重装
查看>>