【题目链接】:http://codeforces.com/problemset/problem/340/B

【题意】



给你n个点,让你在这里面找4个点构成一个四边形;

求出最大四边形的面积;

【题解】



枚举四边形的对角线上的对顶点;

然后再枚举每一个点;

看看这个点是在这条线的哪一侧;

是左侧和右侧;

是左侧的话;

看看这3个点构成的三角形有没有比当前获取的左侧的三角形大;

右侧的话同理;

最后把两侧得到的最大的三角形合在一起;

就是最大的四边形了;

O(N 3 ) 



【Number Of WA】



0



【完整代码】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,m,rt<<1
  4. #define rson m+1,r,rt<<1|1
  5. #define LL long long
  6. #define rep1(i,a,b) for (int i = a;i <= b;i++)
  7. #define rep2(i,a,b) for (int i = a;i >= b;i--)
  8. #define mp make_pair
  9. #define pb push_back
  10. #define fi first
  11. #define se second
  12. #define ms(x,y) memset(x,y,sizeof x)
  13. #define Open() freopen("D:\\rush.txt","r",stdin)
  14. #define Close() ios::sync_with_stdio(0),cin.tie(0)
  15. typedef pair<int,int> pii;
  16. typedef pair<LL,LL> pll;
  17. const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
  18. const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
  19. const double pi = acos(-1.0);
  20. const int N = 310;
  21. int n,x[N],y[N],ans;
  22. int main(){
  23. //Open();
  24. Close();//scanf,puts,printf not use
  25. //init??????
  26. cin >> n;
  27. rep1(i,1,n){
  28. cin >> x[i] >> y[i];
  29. }
  30. rep1(i,1,n-1){
  31. rep1(j,i+1,n){
  32. int temp1 = -1,temp2 = -1;
  33. int x1 = x[i],y1 = y[i],x2 = x[j],y2 = y[j];
  34. int vx1 = x2-x1,vy1 = y2-y1;
  35. rep1(k,1,n)
  36. if (k!=i && k!=j){
  37. int x3 = x[k],y3 = y[k];
  38. int vx2 = x3-x1,vy2 = y3-y1;
  39. /*
  40. vx1 vy1
  41. vx2 vy2
  42. */
  43. int chaji = vx1*vy2-vx2*vy1;
  44. if (chaji<0){
  45. temp1 = max(temp1,-chaji);
  46. }else if(chaji>0){
  47. temp2 = max(temp2,chaji);
  48. }
  49. }
  50. if (temp1>0 && temp2 >0)
  51. ans = max(ans,temp1+temp2);
  52. }
  53. }
  54. cout << fixed << setprecision(10) << 1.0*ans*0.5<<endl;
  55. return 0;
  56. }

【codeforces 340B】Maximal Area Quadrilateral的更多相关文章

  1. 【codeforces 803C】Maximal GCD

    [题目链接]:http://codeforces.com/contest/803/problem/C [题意] 给你一个数字n;一个数字k; 让你找一个长度为k的序列; 要求这个长度为k的序列的所有数 ...

  2. Maximal Area Quadrilateral CodeForces - 340B || 三点坐标求三角形面积

    Maximal Area Quadrilateral CodeForces - 340B 三点坐标求三角形面积(可以带正负,表示向量/点的不同相对位置): http://www.cnblogs.com ...

  3. Codeforces 340B - Maximal Area Quadrilateral (计算几何)

    Codeforces Round #198 (Div. 2) 题目链接:Maximal Area Quadrilateral Iahub has drawn a set of \(n\) points ...

  4. 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 ...

  5. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  6. 【25.33%】【codeforces 552D】Vanya and Triangles

    time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 755D】PolandBall and Polygon

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【codeforces 766B】Mahmoud and a Triangle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 749B】Parallelogram is Back

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. markdown图片设置

    工具:typora 1. 设置图片大小(本节引用自 https://support.typora.io/Resize-Image/) Typora允许使用<img>标签显示图像,也可用于调 ...

  2. eclipse引入svn插件,并将项目同步到svn

    1. eclipse中不存在SVN问题的解决 1.1发现Team->Share project 下没有svn. 1.2下载安装svn插件. 选择help->Eclipse Marketpl ...

  3. 高级函数-sign

    ==========sign函数介绍(补充)===========   sign(n):判断n>0返回1;n=0返回0;n<0返回-1.   select sign(10),sign(0) ...

  4. HDU——T 1498 50 years, 50 colors

    http://acm.hdu.edu.cn/showproblem.php?pid=1498 Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...

  5. lucene构建restful风格的简单搜索引擎服务

    来自于本人博客: lucene构建restful风格的简单搜索引擎服务 本人的博客如今也要改成使用lucene进行全文检索的功能,因此在这里把代码贴出来与大家分享 一,文件夹结构: 二,配置文件: 总 ...

  6. 怎样更好的深入学习andorid

    把主要的控件  基本布局 基本组件  数据存储都熟悉一边,在看网络的时候,有点不知道怎么搞了.由于一直用c开发,但接触socket也不多,这两天把java的socket编程熟悉了下.找了非常多书,可是 ...

  7. 更换oracle 集群网卡(Changing a Network Interface)

     更换oracle 集群网卡(Changing a Network Interface) 假设换网卡前后 网卡名.ip,网关,子网掩码都不变的话,集群层面不许要做额外的操作. 一下操作为更换网卡后 ...

  8. Cordova 5 架构学习 Weinre远程调试技术

    手机上的页面不像桌面开发这么方便调试.能够使用Weinre进行远程调试以方便开发.本文介绍windows下的安装与使用. 安装 使用npm安装.能够执行: ###npm config set regi ...

  9. 研读:AirBag Boosting Smartphone Resistance to Malware Infection

  10. PyCharm基本设置、常用快捷键

    1. 下载安装 PyCharm官方下载地址:  https://www.jetbrains.com/pycharm/download/index.html#section=windows 安装完成后在 ...