题意:给出平面上\(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. matlab: undocumented sprintfc

    今天本想找一个类似于 R 中 paste 的 matlab 函数, 结果在 stackoverflow 上找到一个叫 sprintfc 的函数 (http://stackoverflow.com/qu ...

  2. docker 搭建gitlab

    https://docs.gitlab.com/omnibus/docker/ https://blog.csdn.net/m0_37444820/article/details/81147452 h ...

  3. jmeter之JDBC请求

    jmeter不仅可以测试http请求,也可以执行JDBC请求的测试.本次以mysql为例,介绍JDBC请求如何完成发送 目录 1.环境配置 2.数据库连接配置 3.添加一个JDBC请求 1.环境配置 ...

  4. 【MM系列】SAP ABAP 在选择画面显示输出结果

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 在选择画面显示 ...

  5. Oracle11g安装步骤

    plsql安装等:https://blog.csdn.net/li66934791/article/details/83856225      https://www.cnblogs.com/gaoz ...

  6. AtCoder ABC 140D Face Produces Unhappiness

    题目链接:https://atcoder.jp/contests/abc140/tasks/abc140_d 题目大意 有一对 N 个人, 用字符串 S 表示, S[i] 如果等于 'L' 说明这个人 ...

  7. python3.7.0 安装与配置

    python 3.7.0 X64下载地址: https://www.python.org/ftp/python/3.7.0/python-3.7.0-amd64.exe 更多版本下载请移步到:http ...

  8. 通过JS,用a标签代替form中的submit

    ---恢复内容开始--- 有时候在使用表单的时候,不一定会用到表单中的input_submit来提交表单数据,可能会用a.button等来代替 然后自然而然地想到了用JS中的提交表单数据的动作 < ...

  9. [BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 (Treap+单调队列)

    题面 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发现她们已经结成了几个"群".每只奶牛在吃草的时候有一个独一无二的位置坐标Xi,Yi( ...

  10. python中bytes和str

    1.python中bytes和str Python3 最重要的新特性大概要算是对文本(text)和二进制数据(binary data)作了更为清晰的区分 (1)Python 3.0使用文本和(二进制) ...