题意:给出平面上\(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. 131、TensorFlow保存模型

    # tf.train.Saver类提供了保存和恢复模型的方法 # tf.train.Saver的构造函数 提供了save和恢复的参数选项 # Saver对象提供了方法来运行这些计算节点,制定了写和读的 ...

  2. node后台fetch请求数据-Hostname/IP doesn't match certificate's altnames解决方法

    一.问题背景 基于express框架,node后台fetch请求数据,报错Hostname/IP doesn't match certificate's altnames..... require(' ...

  3. mysql in与or效率比较

    转自[点击]

  4. Markov Decision Process in Detail

    From the last post about MDP, we know the environment consists of 5 basic elements: S:State Space of ...

  5. [6期]Webshell提权服务器登录

    这一期内容较少,分享一点资料给大家吧:https://www.bilibili.com/video/av27708518/?spm_id_from=333.788.b_636f6d6d656e74.9 ...

  6. 21.线程,全局解释器锁(GIL)

    import time from threading import Thread from multiprocessing import Process #计数的方式消耗系统资源 def two_hu ...

  7. jQuery基础--动画操作

    三组基本动画 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset=" ...

  8. app自动化appium使用内置adb命令

    一.Appium-server使用 1.登陆页面 高级设置:可以设置Android 和 IOS 日志级别:dabug非常详尽的日志 记录python代码向他发送的请求以及他在收到请求后做的一系列处理 ...

  9. Ajax局部刷新(使用JS操作)

    对于在不使用Ajax的情况下,使用JS来进行局部刷新,主要有如下的几步: 1. 得到XMLHttpRequest 2. 使用open方法打开连接 3. 设置请求头信息 4. 注册onreadystat ...

  10. [Linux] 009 链接命令

    链接命令:ln 命令名称:ln 命令英文原意:link 命令所在路径:/bin/ln 执行权限:所有用户 语法:ln -s [原文件] [目标文件] 功能描述:生成链接文件 范例: 创建文件 /etc ...