摘要: 思路:这题和1227的求法一样,只不过1227是小数据,暴力下,就能进行预处理。这题的预处理区间期望cost[i][j]需要利用单调性。即假使以pos位置为安排的点,那么这个区间在其左边的概率为l,右边的概率为r,总期望为sum。如果将安排点从pos放到pos-1该区间增加的期望为r*(p[pos].x-p[pos-1].x)减少的期望为l*(p[pos].x-p[pos-1].x)如果减少的超过增加的,那么pos-1就比pos好。#include#include#include#include#include#define Maxn 1010using namespace std;doubl 阅读全文
posted @ 2013-08-17 21:01 fangguo 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 思路:主要就是要把一个每个城市拆为两个点,建一条容量为1,费用为-inf的边,保证每个城市都会被遍历。/*最小费用最大流*/#include#include#include#include#includeusing namespace std;const int Maxn = 1010;const int inf = 1000010;struct Edge{ int v; int val; int cost; int next;}edge[Maxn*100];int head[Maxn],n,g[Maxn][Maxn],m,k;int e;int pre[Maxn], ... 阅读全文
posted @ 2013-08-17 16:50 fangguo 阅读(126) 评论(0) 推荐(0) 编辑