CF1146G Zoning Restrictions

网络流

h<=50?

直接都选择最大的,ans=n*h*h

最小割

考虑舍弃或者罚款

有一个>x就要罚款?

经典取值限制的模型:切糕割!

每个位置的x+1到额外点tot连接inf边

tot向t连接c边

大概这样:

#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
#define pb push_back
#define solid const auto &
#define enter cout<<endl
#define pii pair<int,int>
using namespace std;
typedef long long ll;
template<class T>il void rd(T &x){char ch;x=0;bool fl=false;while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);for(x=numb;isdigit(ch=getchar());x=x*10+numb);(fl==true)&&(x=-x);
}
template<class T>il void output(T x){if(x/10)output(x/10);putchar(x%10+'0');}
template<class T>il void ot(T x){if(x<0) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}namespace Miracle{
const int N=55;
const int P=N*N;
const int inf=0x3f3f3f3f;
int n,m,h;
int s,t;
struct node{int nxt,to;int w;
}e[2*(P+P+N*N)];
int hd[P],cnt=1;
void add(int x,int y,int z){e[++cnt].nxt=hd[x];e[cnt].to=y;e[cnt].w=z;hd[x]=cnt;e[++cnt].nxt=hd[y];e[cnt].to=x;e[cnt].w=0;hd[y]=cnt;
}
int d[P];
int q[P],l,r;
int ans;
int dfs(int x,int flow){int res=flow;if(x==t) return flow;for(reg i=hd[x];i&&res;i=e[i].nxt){int y=e[i].to;if(d[y]==d[x]+1&&e[i].w){int k=dfs(y,min(res,e[i].w));if(!k) d[y]=0;res-=k;e[i].w-=k;e[i^1].w+=k;}   }return flow-res;
}
bool bfs(){memset(d,0,sizeof d);l=1,r=0;q[++r]=s;d[s]=1;while(l<=r){int x=q[l++];for(reg i=hd[x];i;i=e[i].nxt){int y=e[i].to;if(e[i].w&&!d[y]){d[y]=d[x]+1;q[++r]=y;if(y==t) return true;}}}return false;
}
int num(int x,int y){return (x-1)*(h+1)+y+1;
}
int main(){rd(n);rd(h);rd(m);ans=n*h*h;s=0;t=num(n,h)+1;int tot=t;for(reg i=1;i<=n;++i){add(s,num(i,0),inf);for(reg j=0;j<h;++j){add(num(i,j),num(i,j+1),h*h-j*j);}}int l,r,x,c;for(reg i=1;i<=m;++i){rd(l);rd(r);rd(x);rd(c);if(x<h){++tot;add(tot,t,c);for(reg j=l;j<=r;++j){add(num(j,x+1),tot,inf);}}}int flow=0;while(bfs()){while(flow=dfs(s,inf)) ans-=flow;}ot(ans);return 0;
}}
signed main(){Miracle::main();return 0;
}/*Author: *Miracle*
*/

转载于:https://www.cnblogs.com/Miracevin/p/10857458.html

CF1146G Zoning Restrictions相关推荐

  1. CF1146G Zoning Restrictions 最小割

    CF1146G Zoning Restrictions 最小割 题意: 你准备在一条街上建房子.这条街上共有nn个地方可以用来建房子,每个房子高度最高为h.若你建了一个高度为aa的房子,那你将得到a^ ...

  2. cf----2019-08-14(The Doors,Zoning Restrictions Again,Detective Book)

    总在不经意的年生,回首彼岸,纵然发现光景绵长. Three years have passes and nothing changed. It is still raining in London, ...

  3. Codeforces 1146G Zoning Restrictions dp

    Zoning Restrictions 发现从左往右dp没有办法dp, 可以想到最大值的性质, 我们考虑构建笛卡尔树的过程. 如果 i 的l, r 的最大值, 那么经过 i 点的线段可以全部在枚举 i ...

  4. Forethought Future Cup - Elimination Round G. Zoning Restrictions 最大流(最小割)

    题目链接: https://codeforces.com/contest/1146/problem/G 题意: 你现在要给 nnn 个位置制定高度 hi(1<=hi<=H)h_i (1&l ...

  5. Codeforces 1146G Zoning Restrictions

    题目 https://codeforces.com/contest/1146/problem/G 题目翻译 你正在准备在一条路上建房子.这条路上有n个可以建房子的点,它们从左到右编号为1~n.你可以在 ...

  6. codeforces1146G Zoning Restrictions

    题面 题意 在一条路上有标号为1-n的n座房子,每座房子最高为h,若一座房子的高度为x,则这座房子的收益为x*x,有m条限制,每条限制表示如果在l-r之间的所有房子的最大高度超过hi,则罚款ci.问所 ...

  7. 新浪微博授权失败:applications over the unaudited use restrictions

    在用新浪微博授权第三方app时,授权失败,log显示 com.sina.weibo.sdk.exception.WeiboHttpException: {"error":" ...

  8. hibernate 高级查询 query 或查询 or ,Restrictions

    hibernate 高级查询 query 或查询 or ,Restrictions 今天用了写hibernate高级查询时用了Restrictions(当然Expression也是可以以的)这个类.感 ...

  9. 如何在 SAP 电商云里设置 Time Restrictions

    时间限制(Time Restrictions) 允许Commerce Cloud CMS 管理员指定何时向客户显示页面或组件.您只能向变体页面(variant pages)或组件(Components ...

最新文章

  1. android调试步骤,Android16_Android调试步骤
  2. 如何用Neo4j和Scikit-Learn做机器学习任务?| 附超详细分步教程
  3. 雷军在小米直面会丢的面子,在年度演讲都找回来了
  4. 2006_06_16_阿根廷的节日
  5. scala条件替换_scala - 有没有办法用scala中的高阶方法替换嵌套的For循环 - SO中文参考 - www.soinside.com...
  6. oracle生成42位,Oracle HowTo:如何确定Oracle是32 Bit(位)的还是64 Bit(位)的?
  7. kettle 的表输出 table output
  8. Bob‘s Problem
  9. java web 连接linux_如何将javaweb项目部署到linux下
  10. linux fall delay 10,Cell的Rise delay和Fall delay、Rise transition和fall transition
  11. python祝福祖国代码_C语言-笔记一
  12. 【转】如何读一篇论文
  13. java word模板 变量,Java-POI替换Word模板文档中的变量,生成Word文档
  14. 蒙版操作—剪切蒙版制作艺术字
  15. html页面出现504,web生产环境故障页面提示504错误
  16. eMule中的server无法连接问题
  17. 2020.7.6 -- Miller_Rabin和Pollard_Rho算法
  18. echarts实用篇(一)——饼状图
  19. android gif图片闪烁,Android中动态显示gif图片
  20. OpenCV-Python Feature2D 特征点检测(含SIFT/SURF/ORB/KAZE/FAST/BRISK/AKAZE)

热门文章

  1. MacBook上下载安装Mysql
  2. 已经开源的阿里云播放器的播放内核
  3. Java开发内存16g够用不_讨论!现在的你是否还能用16G手机,内存还够不够用?...
  4. JDK新特性-LocalDateTime
  5. 作业成本法中的成本动因分析----by AMT 邓为民
  6. 点云特征提取--vfh
  7. iconfont字体图标以及css字体图标在线制作和使用(推荐)
  8. 使用Telnet连接smtp服务器发送邮件
  9. 【电脑办公软件有哪些】万彩办公大师教程丨重复音频文件探测工具
  10. 求和(单例模式,初始化列表,容器,迭代器)