求凸包面积。求结果后不用加绝对值,这是BBS()排序决定的。

//Ps 熟练了template <class T>之后用起来真心方便= =

//POJ 3348
//凸包面积
//1A 2016-10-15 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#define MAXN (10000 + 10) struct point{
int x, y;
point(){}
point(int X, int Y): x(X), y(Y){}
friend int operator ^ (const point &p1, const point &p2){
return p1.x * p2.y - p1.y * p2.x;
}
friend point operator >> (const point &p1, const point &p2){
return point(p2.x - p1.x, p2.y - p1.y);
}
friend bool operator < (const point &p1, const point &p2){
return (p1.x < p2.x)||(p1.x == p2.x)&&(p1.y < p2.y);
}
}pt[MAXN]; template <class T>
void swap(T &a, T & b){
T t = a;
a = b;
b = t;
} template <class T>
void BBS(T a[], int n){
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
if (a[i] < a[j]) swap(a[j], a[i]);
} double convex_hull(point p[], int n){
int cur = 0;
double area = 0;
BBS(p, n);
while (1){
int tmp = - 1;
for (int i = 0; i < n; i++){
if (cur != i){
if (!(tmp + 1)||((p[cur] >> p[i]) ^ (p[cur] >> p[tmp])) > 0)
tmp = i;
}
}
if (tmp + 1){
area += p[cur] ^ p[tmp];
}
if (!tmp||!(tmp + 1)) return area / 2;
cur = tmp;
}
} int main(){
int n;
freopen("fin.c", "r", stdin);
scanf("%d", &n);
for (int i = 0; i < n; i++){
scanf("%d%d", &pt[i].x, &pt[i].y);
}
printf("%d\n", int(convex_hull(pt, n)/50));
}

POJ 3348 - Cows 凸包面积的更多相关文章

  1. POJ 3348 Cows [凸包 面积]

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9022   Accepted: 3992 Description ...

  2. poj 3348 Cow 凸包面积

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8122   Accepted: 3674 Description ...

  3. POJ 3348 Cows 凸包 求面积

    LINK 题意:给出点集,求凸包的面积 思路:主要是求面积的考察,固定一个点顺序枚举两个点叉积求三角形面积和除2即可 /** @Date : 2017-07-19 16:07:11 * @FileNa ...

  4. poj 3348 Cows 凸包 求多边形面积 计算几何 难度:0 Source:CCC207

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7038   Accepted: 3242 Description ...

  5. POJ 3348 Cows (凸包模板+凸包面积)

    Description Your friend to the south is interested in building fences and turning plowshares into sw ...

  6. POJ 3348 Cows | 凸包模板题

    题目: 给几个点,用绳子圈出最大的面积养牛,输出最大面积/50 题解: Graham凸包算法的模板题 下面给出做法 1.选出x坐标最小(相同情况y最小)的点作为极点(显然他一定在凸包上) 2.其他点进 ...

  7. POJ 3348 Cows | 凸包——童年的回忆(误)

    想当年--还是邱神给我讲的凸包来着-- #include <cstdio> #include <cstring> #include <cmath> #include ...

  8. poj 3348:Cows(计算几何,求凸包面积)

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6199   Accepted: 2822 Description ...

  9. POJ 3348 Cows

    题目大意: 给你n棵树,可以用这n棵树围一个圈,然后在圈里面可以养牛,每个牛需要50平方米的空间,问最多可以养多少牛? 其实就是求一个凸包,计算凸包面积,然后除以50,然后就得到答案,直接上模板了. ...

随机推荐

  1. java io系列14之 DataInputStream(数据输入流)的认知、源码和示例

    本章介绍DataInputStream.我们先对DataInputStream有个大致认识,然后再深入学习它的源码,最后通过示例加深对它的了解. 转载请注明出处:http://www.cnblogs. ...

  2. Win7重装后,如何删除cygwin目录?

    参考: http://blog.csdn.net/zjjyliuweijie/article/details/6577037 http://blog.csdn.net/huangzhtao/artic ...

  3. MongoDB学习笔记一:入门

    文档:多个键及其关联的值『有序』地放置在一起. {"greeting" : "Hello, world!", "foo" : 3}集合:一组 ...

  4. SoftEnther VPN 在Window的使用

    1.首先下载SoftEnther VPN Client 下载地址 2. 下载后,执行vpngate-client-×××.exe 文件 选择安装一个软件部分: SoftEnther VPN Clien ...

  5. [cross compile]cygwin和mingw

    转自:http://blog.csdn.net/embededvc/article/details/6829010 1. MinGW和CygWin/gcc概念 Unix下编译通过的C代码,在win32 ...

  6. maya,mel,eval,stringarray

    mel里,当要eval("client()"),并且要传递stirngarray参数给函数client()时,正确的写法应该是: global proc intermediator ...

  7. 使用springMVC实现文件上传和下载之环境配置与上传

    最近的项目中用到了文件的上传和下载功能,任务分配给了其他的同时完成.如今项目结束告一段落,我觉着这个功能比较重要,因此特意把它提取出来自己进行了尝试. 一. 基础配置: maven导包及配置pom.x ...

  8. activiti自定义流程之整合(七):完成我的申请任务

    在上一篇的获得我的申请中,可以看到js代码中还包含了预览和完成任务的代码,既然上一篇已经罗列了相关代码,这里也就不重复. 那么需要补充的是,在上边的完成任务的js代码中,我们还调用了getTaskFo ...

  9. HTTPS_SSL配置的步骤以及原理说明

    1.单向认证,就是传输的数据加密过了,但是不会校验客户端的来源 2.双向认证,如果客户端浏览器没有导入客户端证书,是访问不了web系统的,找不到地址,想要用系统的人没有证书就访问不了系统HTTPS概念 ...

  10. Python第十二章正则表达式(2)

    1.前提是引入import re 匹配邮箱后缀需要写入r=r'\.com\.cn|\.com|\.cn' r=r'(\w+@\w+(\.com\.con|\.com|\.cn))'ll=re.find ...