【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 ...
随机推荐
- CF739E Gosha is hunting(费用流,期望)
根据期望的线性性答案就是捕捉每一只精灵的概率之和. 捕捉一只精灵的方案如下: 1.使用一个\(A\)精灵球,贡献为\(A[i]\) 2.使用一个\(B\)精灵球,贡献为\(B[i]\) 3.使用一个\ ...
- UVA1583-Digit Generator(紫书例题3.5)
For a positive integer N , the digit-sum of N is defined as the sum of N itself and its digits. When ...
- Android开发进度05
1,今日:目标:完成后台用户的增删改查 2,昨天:完成登录和注册功能 3,收获:熟练了SQLite操作 4,问题:无
- WPF利用radiobutton制作菜单按钮
原文:WPF利用radiobutton制作菜单按钮 版权声明:欢迎转载.转载请注明出处,谢谢 https://blog.csdn.net/wzcool273509239/article/details ...
- jsonp实现原理
jquery 封装在 ajax方法 里面的jsonp jsonp跨域的原理 1:使用script 标签发送请求,这个标签支持跨域访问 2:在script 标签里面给服务器端传递 ...
- 极路由设置共享磁盘密码、跨网访问samba服务
极路由插上移动硬盘后会自动建立samba服务器,但我们没法去配置哪些盘符需要密码,这样只要在同一个wifi下的电脑都能去访问这些东西了,比较弱智.另外我还想再公司中去读写这个移动硬盘. 设置密码 首先 ...
- Linux下基于多线程的echo
准备开始写一些Linux 下网络编程以及多线程的blog,就从这个简单的echo程序开始吧. 在echo的服务端使用多线程与客户进行通信,可以实现一个服务端程序同时连接多个客户的功能.那么,到底在服务 ...
- atitit。流程图的设计与制作 attilax 总结
atitit.流程图的设计与制作 attilax 总结 1. 流程图的规范1 2. 画图语言2 2.1. atitit.CSDN-markdown编辑器2 2.2. js-sequence-diagr ...
- HDU 2841 Visible Trees(容斥定理)
Visible Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- Light OJ 1317 Throwing Balls into the Baskets 概率DP
n个人 m个篮子 每一轮每一个人能够选m个篮子中一个扔球 扔中的概率都是p 求k轮后全部篮子里面球数量的期望值 依据全期望公式 进行一轮球数量的期望值为dp[1]*1+dp[2]*2+...+dp[ ...