题意:给出平面上\(n\)个点,要求选出\(k\)个点,使得这些点形成一个凸包,且凸包内部没有点,求最大面积。无解输出\(0\)。

题解:枚举凸包最左的点\(p\),删除所有在\(p\)左边的点,然后把\(p\)定为原点。将所有点按极角排序,相邻两个点之间连边,那么会形成一个星状多边形,合法的凸包一定在这个多边形内部。

先考虑求出这张图的visibility graph,显然合法的凸包所有边都是visibility graph上的边。求法大概是逆时针枚举所有点,对于每个点维护一个队列维护未来可能加入的边,实际上是对于每个点\(i\),维护所有满足\(ij\)在visibility graph上,并且当前还没找到\(k(k>i)\)使得\(jk\)在visibility graph上的\(j\),详见代码。复杂度\(O(E)\)。

考虑在visibility graph上DP。顺时针枚举所有点,设\(f_{i,j,k}\)表示最后一条选取的边为\(i,j\),选了\(k\)条边的最大面积。转移时可以枚举一个\(l\),如果\(i,j\)和\(l,i\)这两条边可以同时存在(不会使得凸包不满足凸性)则可以转移到\(f_{l,i,k+1}\)。朴素DP复杂度\(O(n^3k)\),可以对于每个点将转移出去和进来的边分别排序后(其实根据求visibility graph的过程,这些边是已经排好序的)双指针+前缀和优化,复杂度\(O(n^2k)\)。

总复杂度\(O(n^3k)\)。

#include<bits/stdc++.h>
using namespace std;
const int N = 210;
typedef long long ll;
typedef double db;
#define pb push_back int gi() {
int x = 0, o = 1;
char ch = getchar();
while((ch < '0' || ch > '9') && ch != '-') {
ch = getchar();
}
if(ch == '-') {
o = -1, ch = getchar();
}
while(ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0', ch = getchar();
}
return x * o;
} struct point {
int x, y;
db k;
point(int x = 0, int y = 0): x(x), y(y) {
k = atan2(y, x);
}
point operator-(const point &A) const {
return point(x - A.x, y - A.y);
}
ll operator%(const point &A) const {
return 1ll * x * A.y - 1ll * y * A.x;
}
bool operator<(const point &A) const {
return k < A.k;
}
} a[N], p[N]; int n, m, tt;
ll f[N][N][55], mx[55], ans = 0;
queue<int> q[N];
vector<int> E[N], G[N]; void add(int x, int y) {
while(!q[x].empty() && (p[q[x].front()] - p[x]) % (p[y] - p[x]) < 0) {
add(q[x].front(), y), q[x].pop();
}
G[x].pb(y), E[y].pb(x), q[y].push(x);
} int main() {
#ifndef ONLINE_JUDGE
freopen("a.in", "r", stdin);
freopen("a.out", "w", stdout);
#endif
cin >> n >> m;
for(int i = 1; i <= n; i++) {
a[i].x = gi(), a[i].y = gi();
}
for(int s = 1; s <= n; s++) {
tt = 0;
for(int i = 1; i <= n; i++) if(a[i].x > a[s].x || (a[i].x == a[s].x && a[i].y > a[s].y)) {
p[++tt] = a[i] - a[s];
}
sort(p + 1, p + tt + 1);
for(int i = 1; i <= tt; i++) {
E[i].clear(), G[i].clear();
while(!q[i].empty()) {
q[i].pop();
}
}
for(int i = 1; i < tt; i++) {
add(i, i + 1);
}
memset(f, 0xc0, sizeof(f));
for(int i = tt; i; i--) {
memset(mx, 0xc0, sizeof(mx));
reverse(E[i].begin(), E[i].end());
int cur = G[i].size() - 1;
for(auto j : E[i]) {
f[i][j][1] = p[j] % p[i];
while(~cur && (p[j] - p[i]) % (p[G[i][cur]] - p[i]) < 0) {
for(int k = 1; k < m; k++) {
mx[k] = max(mx[k], f[G[i][cur]][i][k]);
}
--cur;
}
for(int k = 1; k < m; k++) {
f[i][j][k + 1] = mx[k] + p[j] % p[i];
}
}
}
for(int i = 1; i <= tt; i++)
for(auto j : E[i]) {
ans = max(ans, f[i][j][m - 2]);
}
}
printf("%.2lf\n", 1.0 * ans / 2);
return 0;
}

[CF852H]Bob and stages的更多相关文章

  1. POJ1704 Georgia and Bob

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9771   Accepted: 3220 Description Georg ...

  2. 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  3. bzoj4730: Alice和Bob又在玩游戏

    Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...

  4. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  5. AASM rule of scoring sleep stages using EEG signal

    Reference: AASM (2007). The AASM Manual for the Scoring of Sleep and Associated Events: Rules, Termi ...

  6. Alice and Bob 要用到辗转相减

    Alice and BobTime Limit: 1 Sec  Memory Limit: 64 MBSubmit: 255  Solved: 43 Description Alice is a be ...

  7. sdutoj 2608 Alice and Bob

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...

  8. hdu 4268 Alice and Bob

    Alice and Bob Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  9. [翻译]Bob大叔:反思极限编程

    译者注: Bob大叔14年后再次谈论极限编程.极限编程经历了14年的风风雨雨后,Bob大叔将会给它怎么样的定义那? 在我手中拿着的一本白皮薄书,在14年前彻底的改变了软件世界.这本书的标题是解析极限编 ...

随机推荐

  1. JS-关闭当前窗口

    不提示直接关闭 默认有提示,若希望不提示直接关闭则需要使用(并非兼容全部浏览器) window.opener=null; window.open('','_self'); window.close() ...

  2. 京东商品评论的分类预测与LSA、LDA建模

    (一)数据准备 1.爬取京东自营店kindle阅读器的评价数据,对数据进行预处理,使用机器学习算法对评价文本进行舆情分析,预测某用户对本商品的评价是好评还是差评.通过数据分析与模型分析,推测出不同型号 ...

  3. upc组队赛18 THE WORLD【时间模拟】

    THE WORLD 题目链接 题目描述 The World can indicate world travel, particularly on a large scale. You mau be l ...

  4. Win10.资料

    1.Win10版本consumer editions和business editions有什么区别?(http://www.winwin7.com/JC/10722.html) 2.密钥 win10 ...

  5. mysql行锁和死锁检测

    行锁顾名思义,就是针对单行数据加锁,在mysql中,锁的实现是由引擎层实现的,MyISAM引擎就不支持行锁 不支持行锁就意味着并发控制只能使用表锁,也就是说同一时间,在这个表上只能有一个更新在执行,这 ...

  6. 23.协程的使用场景,高I/O密集型程序

    import time def one_hundred_millionA(): start_time = time.time() i = 0 for _ in range(100000000): i ...

  7. Oracle基本操作练习(一)

    --创建表空间 create tablespace test datafile 'c:\test.dbf' size 100m autoextend on next 10m; --删除表空间 drop ...

  8. EF - order by specific values

    List<string> s = new List<string>() { "A", "家", "帮", " ...

  9. 链接层-UDP

    五大特点:无连接,不可靠,面向报文传输,没有拥塞控制,首部开销小

  10. python学习三十五天函数递归的用法

    python函数递归就是自己调用自己,无限循环,但是python限制了调用的次数1000次,就会终止,递归用在栏目分类,采集程序比较多,下面简单说函数递归用法和实例 1,函数递归用法 def func ...