题干:

Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one which has all four vertices in the set of special points. Given the set of special points, please calculate the maximal area of a special quadrilateral.

Input

The first line contains integer n (4 ≤ n ≤ 300). Each of the next n lines contains two integers: xiyi ( - 1000 ≤ xi, yi ≤ 1000) — the cartesian coordinates of ith special point. It is guaranteed that no three points are on the same line. It is guaranteed that no two points coincide.

Output

Output a single real number — the maximal area of a special quadrilateral. The answer will be considered correct if its absolute or relative error does't exceed 10 - 9.

Examples

Input

5
0 0
0 4
4 0
4 4
2 3

Output

16.000000

Note

In the test example we can choose first 4 points to be the vertices of the quadrilateral. They form a square by side 4, so the area is 4·4 = 16.

题目大意:

给你n个点,让你从这些点里面寻找4个点,使得四边形的面积最大。当然题目说了没有三个点在一条线上,没有重合的点。

解题报告:

这题看起来不难啊,,把四个点拆成两个三角形然后枚举2+1+1,三重循环就搞定了,,但是这题还是很坑的啊,,WA23的同党肯定不少吧,,看这个简单的B题当时cf比赛的时候比D过题的人都少(不过也可能因为这场的D确实简单,看懂了就是个模板题)

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
const double eps = 1e-8;
int sgn(double x) {if(fabs(x) < eps)return 0;if(x < 0) return -1;return 1;
}
struct Point {double x,y;int id;Point() {}Point(double x,double y):x(x),y(y) {}Point operator -(const Point &b)const {return Point(x - b.x,y - b.y);}double operator ^(const Point &b)const {return x*b.y - y*b.x;}double operator *(const Point &b)const {return x*b.x + y*b.y;}
} p[1005];
double ans,ans1,ans2;
int main()
{int n;cin>>n;for(int i = 1; i<=n; i++) scanf("%lf%lf",&p[i].x,&p[i].y),p[i].id = i;for(int i = 1; i<=n; i++) {for(int j = 1; j<=n; j++) {ans1=ans2=-1.0;for(int k = 1; k<=n; k++) {if(k == i || k == j) continue;double tmp = (p[k]-p[i])^(p[j]-p[i]); if(sgn(tmp) > 0) ans1 = max(ans1,tmp);if(sgn(tmp) < 0) ans2 = max(ans2,-tmp);}if(ans1==-1.0 || ans2 == -1.0) continue;//这么用还是小心点、、、
//          cout << i << "***"<<j<< "***";
//          cout << ans1+ans2<<endl;ans = max(ans,ans1+ans2);}}printf("%.8f\n",ans/2);return 0 ;}
/*
4
0 0
0 5
5 0
1 1
*/

总结:

sgn函数要用啊,,,double别直接等号判断,,很危险、、

这是个坑啊,,还是自己太不小心了、、

【CodeForces - 340B 】Maximal Area Quadrilateral (计算几何,枚举,有坑)相关推荐

  1. CodeForces - 803C Maximal GCD(贪心 + 枚举)

    链接一 链接二 You are given positive integer number n. You should create such strictly increasing sequence ...

  2. Codeforces340B Maximal Area Quadrilateral

    题意:输入n个点(n<300),找出4个点组成4边形(凸四边),问最大面积多少? 题解:一个四边形是由两个三角形组成,直接枚举对角线,接下来枚举点,记录最小的和最大的叉积,就是距离这条线最远的两 ...

  3. 【CodeForces - 144B 】Meeting (暴力枚举,水题,计算几何)

    题干: The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super D ...

  4. CodeForces 444C. DZY Loves Physics(枚举+水题)

    转载请注明出处:http://blog.csdn.net/u012860063/article/details/37509207 题目链接:http://codeforces.com/contest/ ...

  5. Codeforces 813B The Golden Age(数学+枚举)

    题目大意:如果一个数t=x^a+y^b(a,b都是大于等于0的整数)那就是一个unlucky数字.给你x,y,l,r(2 ≤ x, y ≤ 10^18, 1 ≤ l ≤ r ≤ 10^18),求出l到 ...

  6. 【CodeForces - 485D】Maximum Value (枚举,用数组离散化,数学,取模运算,因子,筛法)

    题干: You are given a sequence a consisting of n integers. Find the maximum possible value of  (intege ...

  7. codeforces 849B Tell Your World(计算几何)

    题意: 给你一个直角坐标系,上面有n个点,问你能不能画两条不重合的平行线,使得每条平行线至少经过一个点,且所有的点都在其中一条平行线上. 思路: 提取前三个点,根据题目要求,这两条线其中一条必经过前三 ...

  8. codeforces 46C Hamsters and Tigers(枚举)

    题目链接 Hamsters and Tigers time limit per test 2 seconds memory limit per test 256 megabytes

  9. Codeforces - tag::data structures 大合集 [占坑 25 / 0x3f3f3f3f]

    371D 小盘子不断嵌套与大盘子,最后与地面相连,往里面灌水,溢出部分会往下面流,求每次操作时当前的盘子的容量 其实这道题是期末考前就做好了的.. 链式结构考虑并查集,然后没了(求大佬解释第一个T的点 ...

最新文章

  1. 利用urllib2实现http post请求源码示例
  2. FZU Problem 2238 Daxia Wzc's problem
  3. python程序设计sgnx_Python中符号函数的数值积分
  4. arkit unity_凯蒂猫! 如何使用ARKit和Unity制作增强现实应用程序。
  5. 深度 | 理解深度学习中的卷积
  6. IAM页,IAM链表,分配单元
  7. MATLAB中的eps
  8. C++ boost multiprecision类型转换 u256转double
  9. Eigen教程(5)
  10. EICU数据库安装教程
  11. adb命令刷机vivox20_vivo手机如何双清?vivo双wipe刷机教程
  12. 新西兰计算机设计专业,2020年出国新西兰学习计算机专业的要求是什么?
  13. R语言caret包preProcess()标准化出现错误: Matrices or data frames are required for preprocessing
  14. 技术总监7年总结,如何进行正确的沟通?
  15. keil5图标变成白色_桌面图标出现白块,显示图标异常的解决方法
  16. 聊聊directory traversal attack
  17. evolution邮箱_b2evolution简介
  18. 【微信小程序】小程序实现文件的上传及预览,以PDF文件为例。
  19. 迭代器的定义与自定义一个迭代器
  20. DPDK mbuf引用计数出错的分析

热门文章

  1. html5本地存储论坛,Web Storage--HTML5本地存储
  2. D. Flowers
  3. 143. 最大异或对
  4. 计算机过程控制系统教材,过程控制系统-样章试读.PDF
  5. java版本streamgobbler_java调用本地命令 Runtime class's exec() method
  6. python可以在linux运行_服务器(Linux)上运行python总结
  7. 用计算机求正有理数算术平方根的步骤,用计算器求算数平方根、用有理数估计算数平方根的大小.ppt...
  8. android ui状态栏高度,Android--状态栏高度,导航栏高度,Window高度,DecorView高度,heightPixels...
  9. 正在读取软件包列表... 有错误!
  10. WinCE 修改系统字体 开启ClearType平滑字体