【codeforces 340B】Maximal Area Quadrilateral
【题目链接】:http://codeforces.com/problemset/problem/340/B
【题意】
给你n个点,让你在这里面找4个点构成一个四边形;
求出最大四边形的面积;
【题解】
枚举四边形的对角线上的对顶点;
然后再枚举每一个点;
看看这个点是在这条线的哪一侧;
是左侧和右侧;
是左侧的话;
看看这3个点构成的三角形有没有比当前获取的左侧的三角形大;
右侧的话同理;
最后把两侧得到的最大的三角形合在一起;
就是最大的四边形了;
O(N 3 )
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("D:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0),cin.tie(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 310;
int n,x[N],y[N],ans;
int main(){
//Open();
Close();//scanf,puts,printf not use
//init??????
cin >> n;
rep1(i,1,n){
cin >> x[i] >> y[i];
}
rep1(i,1,n-1){
rep1(j,i+1,n){
int temp1 = -1,temp2 = -1;
int x1 = x[i],y1 = y[i],x2 = x[j],y2 = y[j];
int vx1 = x2-x1,vy1 = y2-y1;
rep1(k,1,n)
if (k!=i && k!=j){
int x3 = x[k],y3 = y[k];
int vx2 = x3-x1,vy2 = y3-y1;
/*
vx1 vy1
vx2 vy2
*/
int chaji = vx1*vy2-vx2*vy1;
if (chaji<0){
temp1 = max(temp1,-chaji);
}else if(chaji>0){
temp2 = max(temp2,chaji);
}
}
if (temp1>0 && temp2 >0)
ans = max(ans,temp1+temp2);
}
}
cout << fixed << setprecision(10) << 1.0*ans*0.5<<endl;
return 0;
}
【codeforces 340B】Maximal Area Quadrilateral的更多相关文章
- 【codeforces 803C】Maximal GCD
[题目链接]:http://codeforces.com/contest/803/problem/C [题意] 给你一个数字n;一个数字k; 让你找一个长度为k的序列; 要求这个长度为k的序列的所有数 ...
- Maximal Area Quadrilateral CodeForces - 340B || 三点坐标求三角形面积
Maximal Area Quadrilateral CodeForces - 340B 三点坐标求三角形面积(可以带正负,表示向量/点的不同相对位置): http://www.cnblogs.com ...
- Codeforces 340B - Maximal Area Quadrilateral (计算几何)
Codeforces Round #198 (Div. 2) 题目链接:Maximal Area Quadrilateral Iahub has drawn a set of \(n\) points ...
- Codeforces Round #198 (Div. 2) B. Maximal Area Quadrilateral
B. Maximal Area Quadrilateral time limit per test 1 second memory limit per test 256 megabytes input ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【25.33%】【codeforces 552D】Vanya and Triangles
time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...
- 【codeforces 755D】PolandBall and Polygon
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 766B】Mahmoud and a Triangle
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 749B】Parallelogram is Back
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- HDU 4458 Shoot the Airplane( 判断点在多边形内外 )
链接:传送门 题意:这个游戏是一个2D打飞机游戏,飞机以速度 v 水平飞行,它是一个简单的多边形,玩家从( 0 , 0 )向上射击,子弹有一个出速度 b ,子弹可以看作一个点,打中飞机边缘是无法击落飞 ...
- [洛谷P3697]开心派对小火车
题目:洛谷P3697 题目大意是有各站停列车(慢车,相邻2站时间A)和特急列车(相邻2站时间B),特急列车在特定站点停靠. 现在加一种快速列车(相邻2站时间C,A>C>B),停靠K站(包括 ...
- java SSM多操作注解回滚
在业务操作时难免会遇到一个业务多操作,会用到事物回滚这里写了一个简单的多操作失败事物回滚案例 在这之前你需要在你的applicationContext-mybatis.xml中配置: <!-- ...
- echarts图表属性说明
参考博客: https://blog.csdn.net/luanpeng825485697/article/details/76691965
- (转载)使用Maven构建多模块项目
原文:https://www.cnblogs.com/xdp-gacl/p/4242221.html#undefined 在平时的Javaweb项目开发中为了便于后期的维护,我们一般会进行分层开发,最 ...
- Java基础学习总结(55)——java8新特性:stream
java作为开发语言中的元老已经度过了很多年,最新的java8为我们带来了一些新特性,这些特性可以在以后的工作中为我们的开发提供更多的便捷,现在就让我们看看最新的函数式编程风格怎么在实际的开发中使用. ...
- Linux Mint 17.1 安装全配置
Linux Mint 17.1 安装全配置 I. 前言 由于自己的本子出现了一些故障需要重新安装系统,就上网看看今年4,5月份发布的一些新的发行版来试试.原先电脑上安装的是opensuse13.2, ...
- stl之hash_map
- 微软版UnityVs横空出世,究竟是谁成就了谁?
在移动互联网浪潮持续发力下,手游行业也异常火热.在现在的手游行业,Unity3d无疑是最耀眼的哪颗星.一直觉得Unity面向设计师是友好的,对程序猿这边并非非常友好. 2012年用Unity时开发工具 ...
- redis的javaclientJedis简单封装
经过我们团队的一番讨论,终于决定使用redis来进行我们的业务缓存.redis会将数据缓存到内存中,执行效率会非常快.同一时候异步将数据写入到磁盘中.进行持久化. 且redis支持主从同步,支持分布式 ...