原题链接:http://codevs.cn/problem/1273/

风战

题目描述 Description

Colonel Trapp is trapped! For several days he has been fighting General Position on a plateau and his mobile command unit is now stuck at (0, 0), on the edge of a cliff. But the winds are changing! The Colonel has a secret weapon up his sleeve: the “epsilon net.” Your job, as the Colonel’s chief optimization officer, is to determine the maximum advantage that a net can yield.

上校陷入了困境!几天以来他一直在高原上战斗并且它的移动指挥单位现在停留在将军位置(0,0),悬崖边上。但是风是在变的!上校有一个秘密武器在他的袖子上:E网(希腊字母epsilon)。作为上校的最优方案工作员,你的工作,就是确定最优的网,使敌人投降。

The epsilon net is a device that looks like a parachute, which you can launch to cover any convex shape. (A shape is convex when, for every pair p,q of points it contains, it also contains the entire line segment pq.) The net shape must include the launch point (0,0).

E网是一个像降落伞的装置,你可以把它弄成任何凸多边形。

The General has P enemy units stationed at fixed positions and the Colonel has T friendly units. The advantage of a particular net shape equals the number of enemy units it covers, minus the number of friendly units it covers. The General is not a unit.

这个高地有P个敌人单位驻扎在固定的地点,上校有T个友军单位。最好的网的形状应该使得它能覆盖的敌人单位数减去自己人单位数的值最大。将军不是个单位。

You can assume that • no three points (Trapp’s position (0,0), enemy units, and friendly units) lie on a line, • every two points have distinct x-coordinates and y-coordinates, • all co-ordinates (x,y) of the units have y > 0, • all co-ordinates are integers with absolute value at most 1000000000, and • the total number P + T of units is between 1 and 100.

你可以假设没有三个点在同一线上,每两个点有明确的横纵坐标,所有单位纵坐标大于0,所有坐标都是整数绝对值最大1000000000,并且单位总数在1到100之间。

输入描述 Input Description

The first line contains P and then T, separated by spaces. Subsequently there are P lines of the form xy giving the enemy units’ co-ordinates, and then T lines giving the friendly units’ co- ordinates.

输入会是P,T。然后P行敌人坐标,T行友军坐标

输出描述 Output Description

Output a single line with the maximum possible advantage.

输出仅一行,表示最优解。

样例输入 Sample Input

5 3
-8 4
-7 11
4 10
10 5
8 2
-5 7
-4 3
5 6

样例输出 Sample Output

3

题解

题目翻译有误,凸多边形必须包含原点
由于数据量很小,我们可以O(n^2)暴力枚举所有顶点为原点的三角形,O(n)计算三角形中敌人数减去友军数的值,再进行O(n^3)的DP即可AC。

代码
#include<bits/stdc++.h>
#define db double
using namespace std;
const int M=1005;
struct pt{int x,y,t;db k;};
bool operator <(pt a,pt b){return a.k<b.k;}
pt operator -(pt a,pt b){return (pt){a.x-b.x,a.y-b.y};}
long long operator *(pt a,pt b){return 1ll*a.x*b.y-1ll*a.y*b.x;}
pt p[M];
int n,m,trag[M][M],dp[M][M];
void in()
{scanf("%d%d",&n,&m);for(int i=1;i<=n;++i)scanf("%d%d",&p[i].x,&p[i].y),p[i].t=1,p[i].k=atan2(p[i].y,p[i].x);for(int i=1;i<=m;++i)scanf("%d%d",&p[i+n].x,&p[i+n].y),p[i+n].t=-1,p[i+n].k=atan2(p[i+n].y,p[i+n].x);n+=m;
}
void ac()
{int ans=0;sort(p+1,p+1+n);for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)for(int k=i+1;k<j;++k)if((p[i]-p[k])*(p[j]-p[k])>0)trag[i][j]+=p[k].t;for(int i=1;i<=n;++i){dp[i][0]=p[i].t;for(int j=1;j<i;++j)for(int k=0;k<j;++k)if((p[k]-p[i])*(p[j]-p[i])>0)dp[i][j]=max(dp[i][j],dp[j][k]+trag[j][i]+p[i].t);}for(int i=1;i<=n;++i)for(int j=1;j<i;++j)ans=max(ans,dp[i][j]);printf("%d",ans);
}
int main()
{in();ac();return 0;
}

Code[VS]1273 风战相关推荐

  1. MYSQL ERROR CODE 错误编号的意义

    mysql error code(备忘) 转1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能删除数据库文件 ...

  2. 如何在团队中做好Code Review

    一.Code Review的好处 想要做好Code Review,必须让参与的工程师充分认识到Code Review的好处 1.互相学习,彼此成就 无论是高手云集的架构师团队,还是以CURD为主的业务 ...

  3. Pyinstaller 打包 torch 后执行失败 OSError: could not get source code

    1. 问题现象 系统环境 Python 3.6.9 torch 1.2.0 torchvision 0.4.0 Pyinstaller 4.5.1 Pyinstaller 打包 torch 后执行失败 ...

  4. VS Code 安装 Go 插件、自定义扩展配置、断点调试

    1. 安装插件 使用快捷键 Ctrl+Shift+X 打开插件安装页面,安装 Go 插件. 2. 自定义扩展配置 使用快捷键 Ctrl+, 打开自定义配置页,编辑 settings.json ,定义与 ...

  5. VS Code 配置调试参数、launch.json 配置文件属性、task.json 变量替换、自动保存并格式化、空格和制表符、函数调用关系、文件搜索和全局搜索、

    1. 生成配置参数 对于大多数的调试都需要在当前项目目录下创建一个 lanch.json 文件,位置是在当前项目目录下生成一个 .vscode 的隐藏文件夹,在里面放置一些配置内容,比如:settin ...

  6. VS Code 安装插件、自定义模板、自定义配置参数、自定义主题、配置参数说明、常用的扩展插件

    1. 下载和官网教程 下载地址:https://code.visualstudio.com/ 官方教程:https://code.visualstudio.com/docs 2. 安装插件 安装扩展插 ...

  7. VS Code 离线安装插件方法

    本文以离线安装 C/C++ 插件为例进说明,其它语言的插件的离线安装方法类似. 离线安装 C/C++ 插件相对比较麻烦一些,主要是因为 C/C++ 插件还依赖其他需要在线下载的组件: C/C++ la ...

  8. 离线安装Visual Studio Code插件

    在使用Visual Studio Code 开发时候,有时可能会碰到需要离线安装插件的情况.这时候就需要单独下载插件包,本文就以C/C++插件包为例说明如何离线安装Visual Studio Code ...

  9. 解决 win10 pycurl安装出错 Command python setup.py egg_info failed with error code 10 编译安装包 安装万金油...

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/yexiaohhjk/article/d ...

  10. pycharm debug后会出现 step over /step into/step into my code /force step into /step out 分别表示...

    1.debug,全部打印 2.打断点debug,出现单步调试等按钮,只运行断点前 3.setup over 调试一行代码 4.setup out 运行断点后面所有代码 5.debug窗口显示调试按钮 ...

最新文章

  1. java编程思想第四版第三章要点习题
  2. 爬虫学习笔记(十六)—— Selenium
  3. -Wl,-rpath=
  4. U3D+SVN: 两份相同资源放在不同目录下导致META的更改
  5. 实现java RPC框架
  6. react-router-dom v6.1.1 使用方式
  7. 轻量级的ORM框架 fluentdata
  8. Introduce Explaining Variable(引入解释性变量)
  9. IE浏览器怎么清理缓存
  10. VIP4.0-MQ消息中间件在分布式系统中的作用
  11. Madagascar的自定义浮点型函数--对数函数
  12. JEECG传统版问题分析
  13. 版本化SQL Server数据库
  14. HG255D[OpenWrt]从入门到精通
  15. 【微信支付】springboot 微信app支付包括回调通知
  16. 逻辑结构与存储结构关系
  17. 2021牛客暑期多校训练营10 F题: Train Wreck
  18. kingston DataTraveler G2 4G U盘量产成功
  19. 音视频技术开发周刊 85期
  20. 微信支付凭证关联开发票功能的配置

热门文章

  1. git提交过滤target文件 idea_详解如何在IntelliJ IDEA中使用.ignore插件忽略不必要提交的文件...
  2. 西门子S7系列中间人攻击:PLC探测和流量分析(二)
  3. webpack3基础总结
  4. Python基础知识之二
  5. Mysql主从架构的复制原理及配置详解
  6. LeetCode--Longest Common Prefix
  7. javascript(定时函数)
  8. TFS使用指南——从服务器上获取最新的项目文件
  9. 依赖注入应该慎用,测试可用测试框架帮忙
  10. 对于相同Bean,在父应用上下文中定义的切面,在子应用上下文中会生效吗?