【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 ...
随机推荐
- js-数组和字符串转化
一.数组=>字符串 需要将数组元素用某个字符连接成字符串,示例代码如下: var arr, str;arr = new Array(0,1,2,3,4);str = arr.join(" ...
- phpMyAdmin 高级功能尚未完全设置,部分功能未激活(转载)
phpMyAdmin 高级功能尚未完全设置,部分功能未激活.请点击这里查看原因. 第一步: 使用Mysql管理员帐号通过phpmyadmin登陆,然后点击“导入”,然后点击“浏览”按钮,找到phpmy ...
- php 与 nginx 的两种处理方式
1.IP:Port 监听方式 php-fpm docker pull PHP:2.4-alpine nginx.conf fastcgi_pass 127.0.0.1:9000; php-fpm 在容 ...
- angular-resource
上一篇中讲到使用$http同服务器进行通信,但是功能上比较简单,angularjs还提供了另外一个可选的服务$resource,使用它可以非常方便的同支持restful的服务单进行数据交互. 安装 n ...
- Android学习之GridView图片布局适配经验
開始解说这篇博客之前,我想问一下,当布局相似GridView这样的多列布局时,我们该怎么布局,才干更好的去适配呢? 扣张图来展示一下 比如这样的需求,三张图片均分屏幕 实现方法: 1.切图固定,比如是 ...
- VC6.0VB6.0 Scratch等软件
VC6.0VB6.0 Scratch等软件 http://pan.baidu.com/s/1nv4hJrb
- servlet调用的几种方式
參见 文库/java/javaEE全新学习教程2.2节 1.通过URL调用 2通过提交表单 3超链接 4 javascript写一个函数,调用这个函数 1,首先在project的WebRoot目录下建 ...
- VS2008执行MFC程序,提示microsoft incremental linker已停止工作解决方法
事实上这边是由于设置有问题.详细的解决方式例如以下: 第一步:点击项目->"你的文件"属性->配置属性->链接器->启用增量链接 将 是(/INCRE ...
- Linux 设备文件的创建和mdev
引子 本文是嵌入式企鹅圈开篇--<linux字符设备驱动剖析>的姐妹篇,在上述文章里面我们具体描写叙述了字符设备驱动框架涉及的驱动注冊.通过设备文件来訪问驱动等知识.并明白通过device ...
- linux怎么开启telnet服务
1>编辑telent的配置文件/etc/xinetd.d/telnet 如下: (设置disable = no,也就是开启telnet服务) service telnet { disable = ...