【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 vy1vx2 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;
}
转载于:https://www.cnblogs.com/AWCXV/p/7626265.html
【codeforces 340B】Maximal Area Quadrilateral相关推荐
- 【CodeForces - 340B 】Maximal Area Quadrilateral (计算几何,枚举,有坑)
题干: Iahub has drawn a set of n points in the cartesian plane which he calls "special points&quo ...
- 【CodeForces - 144C】Anagram Search(尺取,滑窗问题,处理字符串计数)
题干: A string t is called an anagram of the string s, if it is possible to rearrange letters in t so ...
- 【CodeForces - 574B】Bear and Three Musketeers (枚举边,思维,优秀暴力)
题干: Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Ri ...
- 【CodeForces - 608C】Chain Reaction (二分 或 dp ,思维)
题干: 题目大意: 题意是在一条直线上坐落着不同位置的灯塔,每一个灯塔有自己的power level,当作是射程范围.现在从最右边的灯塔开始激发,如果左边的灯塔在这个灯塔的范围之内,那么将会被毁灭.否 ...
- 「一题多解」【CodeForces 85D】Sum of Medians(线段树 / 分块)
题目链接 [CodeForces 85D]Sum of Medians 题目大意 实现一个setsetset,支持插入,删除,求∑a5k+3∑a5k+3\sum a_{5k+3}.注意,setsets ...
- 【CodeForces 997C】Sky Full of Stars(组合计数)
题目链接:[CodeForces 997C]Sky Full of Stars 官方题解:Codeforces Round #493 - Editorial 题目大意:有一个n×nn×nn\times ...
- 【codeforces 812C】Sagheer and Nubian Market
[题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...
- 【codeforces 508B】Anton and currency you all know
[题目链接]:http://codeforces.com/contest/508/problem/B [题意] 给你一个奇数; 让你交换一次数字; 使得这个数字变成偶数; 要求偶数要最大; [题解] ...
- 【codeforces 711B】Chris and Magic Square
[题目链接]:http://codeforces.com/contest/711/problem/B [题意] 让你在矩阵中一个空白的地方填上一个正数; 使得这个矩阵两个对角线上的和; 每一行的和,每 ...
- 【codeforces 807C】Success Rate
[题目链接]:http://codeforces.com/contest/807/problem/C [题意] 给你4个数字 x y p q 要求让你求最小的非负整数b; 使得 (x+a)/(y+b) ...
最新文章
- 深度学习中的优化算法之MBGD
- python自动化测试数据驱动_利用Python如何实现数据驱动的接口自动化测试
- 【渗透测试】初探进程伪装
- Scala集合:ListBuffer的头head和尾tail
- 机器学习数据包之numpy
- 老鼠走迷宫php算法,C语言经典算法 - 老鼠走迷官(一)
- Visual Studio 2010 中JS注释制作
- 非功能性需求_更好的开卡,来聊聊非功能性需求
- 支付宝包下了9家报纸的头版,竟然是为了……
- [模板]匈牙利算法(二分图匹配)
- 13防更新描述文件_描述文件终于来了,iOS 13 也能屏蔽更新!
- 新版换密交友月老盲盒微信小程序源码
- docker pxc mysql_docker安装pxc集群的详细教程
- 世达03017数字万用表的使用
- ROS机器人的远程启动和控制过程
- 嵌入式系统框架----硬件篇
- BUUCTF misc第二页WP
- Java生鲜电商平台-商城后台架构与原型图实战
- zoom会议设置,zoom 如何设置会议密码,每一步骤都要看一下。
- 【网站国际化必备】Asp.Net MVC 集成Paypal(贝宝)快速结账 支付接口 ,附源码demo...