POJ 3348 Cows | 凸包——童年的回忆(误)
想当年……还是邱神给我讲的凸包来着……
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define eps 0.000000001
#define enter putchar('\n')
#define space putchar(' ')
using namespace std;
typedef long long ll;
template <class T>
void read(T &x){
char c;
bool op = 0;
while(c = getchar(), c < '0' || c > '9')
if(c == '-') op = 1;
x = c - '0';
while(c = getchar(), c >= '0' && c <= '9')
x = x * 10 + c - '0';
if(op) x = -x;
}
template <class T>
void write(T x){
if(x < 0) putchar('-'), x = -x;
if(x >= 10) write(x / 10);
putchar('0' + x % 10);
}
const int N = 10005, INF = 0x3f3f3f3f;
int n, top, ans;
struct point {
int x, y;
point(){}
point(int _x, int _y): x(_x), y(_y){}
point operator - (point b) const{
return point(x - b.x, y - b.y);
}
int operator * (point b){
return x * b.y - y * b.x;
}
int norm(){
return x * x + y * y;
}
} p[N], stk[N], root;
bool operator < (const point &a, const point &b){
int det = (a - root) * (b - root);
if(det) return det > 0;
return (a - root).norm() < (b - root).norm();
}
void graham(){
int pos = 0;
root.x = root.y = INF;
for(int i = 1; i <= n; i++)
if(p[i].x < root.x || (p[i].x == root.x && p[i].y < root.y))
root = p[i], pos = i;
if(pos != 1) swap(p[pos], p[1]);
sort(p + 2, p + n + 1);
stk[top = 1] = root;
for(int i = 2; i <= n; i++){
while(top >= 2 && (stk[top] - stk[top - 1]) * (p[i] - stk[top - 1]) < 0) top--;
stk[++top] = p[i];
}
}
void getarea(){
stk[top + 1] = stk[1];
for(int i = 1; i <= top; i++)
ans += stk[i] * stk[i + 1];
}
int main(){
read(n);
for(int i = 1; i <= n; i++)
read(p[i].x), read(p[i].y);
graham();
getarea();
write(ans / 2 / 50), enter;
return 0;
}
POJ 3348 Cows | 凸包——童年的回忆(误)的更多相关文章
- POJ 3348 - Cows 凸包面积
求凸包面积.求结果后不用加绝对值,这是BBS()排序决定的. //Ps 熟练了template <class T>之后用起来真心方便= = //POJ 3348 //凸包面积 //1A 2 ...
- POJ 3348 Cows 凸包 求面积
LINK 题意:给出点集,求凸包的面积 思路:主要是求面积的考察,固定一个点顺序枚举两个点叉积求三角形面积和除2即可 /** @Date : 2017-07-19 16:07:11 * @FileNa ...
- poj 3348 Cows 凸包 求多边形面积 计算几何 难度:0 Source:CCC207
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7038 Accepted: 3242 Description ...
- POJ 3348 Cows (凸包模板+凸包面积)
Description Your friend to the south is interested in building fences and turning plowshares into sw ...
- POJ 3348 Cows [凸包 面积]
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9022 Accepted: 3992 Description ...
- POJ 3348 Cows | 凸包模板题
题目: 给几个点,用绳子圈出最大的面积养牛,输出最大面积/50 题解: Graham凸包算法的模板题 下面给出做法 1.选出x坐标最小(相同情况y最小)的点作为极点(显然他一定在凸包上) 2.其他点进 ...
- poj 3348 Cow 凸包面积
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8122 Accepted: 3674 Description ...
- 2018.07.03 POJ 3348 Cows(凸包)
Cows Time Limit: 2000MS Memory Limit: 65536K Description Your friend to the south is interested in b ...
- poj 3348:Cows(计算几何,求凸包面积)
Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6199 Accepted: 2822 Description ...
随机推荐
- 文字排版 - bootStrap4常用CSS笔记
[文字常用标签] <h1>.<h2>.<h3>.<h4>.<h5>.<h6> 标题类标签,h1字体最大以次类推 <sm ...
- 《Redis设计与实现》阅读笔记(四)--字典
字典 字典,map,是用于保存键值对的抽象数据结构,是hash表实现.字典中的键唯一,通过键来操作值.Redis的数据库使用字典来作为底层实现. 定义 Redis的字典使用哈希表作为底层实现,一个哈希 ...
- Streamr助你掌控自己的数据(1)——教你5分钟上传数据至Streamr
博客说明 所有刊发内容均可转载但是需要注明出处. 教你5分钟上传数据至Streamr 本系列文档主要介绍怎么通过Streamr管理自己的DATA,整个系列包括三篇教程文档,分别是:教你5分钟上传数据至 ...
- 工作小应用:EXCEL查找两列重复数据
工作案例:excel存在A列.B列,需要找出B列没有A列的数据,具体做法如下(以office2007做案例): 1.点击 公式-定义名称 ,选中A列,填写名称“AAA”,选中B列,填写名称“BBB”: ...
- python数据分析画图体验
对于numpy的函数,pands等,不是很熟,我来copy一下code,敲击一下,找找感觉. 默认的导入包import numpy as npimport matplotlib.pyplot as p ...
- 转载---VisualStudioCode通过SSH远程编辑文件
最近需要长期修改远端服务器上的代码,调试.vim操作又不是很6,想到了远程操作的办法,找到一篇好用的bolg,记录一下. 原文链接:https://blog.csdn.net/qq_38401919/ ...
- Daily Scrum meeting 2015.11.9
今天主要完成项目最后的调试工作及二轮迭代的准备 下面是今天的Task统计: Member Today’s Task Tomorrow’s Task 江昊 今天,完成前端界面调整,网站发布 调试 杨墨犁 ...
- 【每日scrum】第一次冲刺day3
学习安卓,和小伙伴讨论百度API调用的问题,最后决定自己写地图
- 深入理解mybatis
MyBatis是目前非常流行的ORM框架,它的功能很强大,然而其实现却比较简单.优雅.本文主要讲述MyBatis的架构设计思路,并且讨论MyBatis的几个核心部件,然后结合一个select查询实例, ...
- b6
吴晓晖(组长) 过去两天完成了哪些任务 对手写输入进行了重构,然后重新捋了一下bayes的思路 展示GitHub当日代码/文档签入记录 接下来的计划 推荐算法 还剩下哪些任务 组员:刘帅珍 过去两天完 ...