题意:给定平面上N个点,问是否存在三角形,其面积为S。

思路:选择Y轴,枚举这个Y轴,面积大小只与|y-Y|有关,然后二分,具体的可以先去做BZOJ3707。

具体的:

1,先对点排序,X坐标为第一关键字,Y坐标为第二关键字,从小到大排序。

2,得到C(N,2)条直线,按照它们的斜率为关键字(叉积排序比较准确),从小到大排序。

3,二分答案,对当前直线,我们只处理线段左边(相对来说)的点,左边的点距离当前“Y轴”具有单调性。

而得到当前直线的两个点,相对于下一条直线,其相对位置会发生改变。

简单证明:(瞎证,笔画以下就知道了)

第一个直线L斜率最小,那么它左边的点,到它的相对位置大小,就是第一次排序后的大小:否则L不是斜率最小,易证。

由上一条直线,到下一条直线,对于新的“Y轴”,相对位置改变的只有上一条直线的两点:否则斜率大小有误,易证。

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
typedef long long ll;
const int maxn=;
struct Point {
int x,y;
bool operator<(const Point& B) const {
return x^B.x?x<B.x:y<B.y;
}
}P[maxn];
typedef Point Vector;
Vector operator - (Vector u, Vector v) { return (Vector){u.x-v.x,u.y-v.y}; }
Vector operator + (Vector u, Vector v) { return (Vector){u.x+v.x,u.y+v.y}; }
ll Cross(Vector u,Vector v) { return 1ll * u.x * v.y - 1ll * u.y * v.x; }
struct Segment {
int u, v;
Vector p;
bool operator<(const Segment& B) const {
return Cross(p, B.p)>;
}
}A[maxn*maxn];
int N,M,pos[maxn]; ll S;
int main() {
cin>>N>>S; S<<=1LL;
rep(i,,N) cin>>P[i].x>>P[i].y;
sort(P+,P+N+);
rep(i,,N) pos[i]=i;
rep(i,,N) rep(j,i+,N) A[++M]=(Segment){i,j,P[i]-P[j]};
sort(A+,A+M+);
rep(i,,M) {
int &a=pos[A[i].u],&b=pos[A[i].v];
Vector p=P[b]-P[a];
int l=,r=a-;
while(l<r){
int mid=(l+r+)>>;
if(abs(Cross(p,P[mid]-P[a]))>=S) l=mid;
else r=mid-;
}
if(abs(Cross(p,P[l]-P[a]))==S){
printf("Yes\n%d %d\n%d %d\n%d %d\n", P[a].x, P[a].y, P[b].x, P[b].y, P[l].x, P[l].y);
return ;
}
swap(a,b);
swap(P[a],P[b]);
}
puts("No");
return ;
}

CodeForces - 1019D(BZOJ3707圈地):Large Triangle (几何,找面积为S的三角形)的更多相关文章

  1. POJ - 2079:Triangle (旋转卡壳,求最大三角形)

    Given n distinct points on a plane, your task is to find the triangle that have the maximum area, wh ...

  2. 【codeforces 766B】Mahmoud and a Triangle

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

  3. codeforces 558B. Amr and The Large Array 解题报告

    题目链接:http://codeforces.com/problemset/problem/558/B 题目意思:给出一个序列,然后找出出现次数最多,但区间占用长度最短的区间左右值. 由于是边读入边比 ...

  4. codeforces A. Vasily the Bear and Triangle 解题报告

    题目链接:http://codeforces.com/problemset/problem/336/A 好简单的一条数学题,是8月9日的.比赛中没有做出来,今天看,从pupil变成Newbie了,那个 ...

  5. Codeforces Round #239 (Div. 2) C. Triangle

    time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard o ...

  6. Codeforces Round #512 D - Vasya and Triangle

    D - Vasya and Triangle #include<bits/stdc++.h> using namespace std; #define LL long long LL gc ...

  7. A. Srdce and Triangle 几何题

    链接:https://www.nowcoder.com/acm/contest/104/A来源:牛客网 题目描述 Let  be a regualr triangle, and D is a poin ...

  8. [CF1019D]Large Triangle[极角排序+二分]

    题意 给出平面上 \(n\) 个点 \((x_i, y_i)\),问是否存在三个点构成的三角形的面积恰好为 \(S\) ,有的话,输出任意一组解即可. \(n\leq 2000\) 分析 BZOJ37 ...

  9. CodeForces - 1017E :The Supersonic Rocket (几何+KMP,判定凸包是否同构)

    After the war, the supersonic rocket became the most common public transportation. Each supersonic r ...

随机推荐

  1. C语言基础知识【存储类】

    C 存储类1.存储类定义 C 程序中变量/函数的范围(可见性)和生命周期.这些说明符放置在它们所修饰的类型之前autoregisterstaticextern2.auto 只能用在函数内,即 auto ...

  2. ANDROID版本号号和版本号名称的重要性介绍

    转载请注明出处http://blog.csdn.net/y150481863/article/details/41249159,来自[http://blog.csdn.net/y150481863] ...

  3. EventBus的使用详解,功能为在Fragment,Activity,Service,线程之间传递消息

    最近跟同事用到了EventBus的使用,之前不太了解EventBus,查阅资料发现EventBus还挺好用的,用法比较简单,下面就把我看到的关于EventBus的博客分享给大家,里面介绍了很多的使用详 ...

  4. git介绍和常用指令

    Git介绍和常用指令 介绍:Git和SVN一样都是版本控制工具.不同的是Git是分布式的,SVN是集中式的.Git开始用可能感觉难点,等你用习惯了你就会觉得svn是有点恐怖.(如果一个项目有好多人一起 ...

  5. 【BZOJ5018】[Snoi2017]英雄联盟 背包

    [BZOJ5018][Snoi2017]英雄联盟 Description 正在上大学的小皮球热爱英雄联盟这款游戏,而且打的很菜,被网友们戏称为「小学生」.现在,小皮球终于受不了网友们的嘲讽,决定变强了 ...

  6. HBase核心技术点

    表的rowkey设计核心思想: 依据rowkey查询最快 对rowkey进行范围查询range 前缀匹配 预分区创建的三种方式 create 'ns1:t1', 'f1', SPLITS => ...

  7. 开关openCV

    #include <cv.h> #include <highgui.h> #include <stdio.h> //开关 ; void switch_callbac ...

  8. 九度OJ 1251:序列分割 (DFS)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:166 解决:34 题目描述: 一个整数数组,长度为n,将其分为m份,使各份的和相等,求m的最大值   比如{3,2,4,3,6} 可以分成{ ...

  9. JQuery日记 5.11 Sizzle选择器(五)

    //设置当前document和document相应的变量和方法 setDocument = Sizzle.setDocument = function( node ) { var hasCompare ...

  10. php7下 xhprof安装与使用

    需要测试下 代码的性能,使用了 xhprof + xhgui 1. 下载xhprof, 这里下载吧 :https://github.com/longxinH/xhprof.git 2, 安装 cd x ...