HDU1392(凸包)】的更多相关文章

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10299    Accepted Submission(s): 3991 Problem Description There are a lot of trees in an area. A peasant wants to buy a rope to…
//极角排序 #include <bits/stdc++.h> #define sqr(x) ((x)*(x)) using namespace std; ],top; struct POI { int x,y; POI() { x=y=; } POI(int _x,int _y) { x=_x;y=_y; } } p[]; int cross(POI x,POI y) { return x.x*y.y-x.y*y.x; } double dis(POI x,POI y) { return s…
第一次做凸包,这道题要特殊考虑下,n=2时的情况,要除以二才行. 我是从最左边的点出发,每次取斜率最大的点,一直到最右边的点. 然后从最左边的点出发,每次取斜率最低的点,一直到最右边的点. #include<stdio.h> #include<math.h> #include<algorithm> #include<string.h> using namespace std; const double eps=1e-9; struct node { doub…
Surround the Trees 此题讨论区里大喊有坑,原谅我没有仔细读题还跳过了坑点. 题意:平面上有n棵树,选一些树用绳子围成一个包围圈,使得所有的树都在这个圈内. 思路:简单凸包入门题,凸包裸模板.在做这个题前建议先去学学:叉积,极角排序,三角形有向面积. 贴上代码以后再复习. struct node { double x,y; } a[N],p[N]; int n,tot;//总点数和凸包上的点数: double dis(node a,node b)//两点间距离 { return…
Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7164    Accepted Submission(s): 2738 Problem Description There are a lot of trees in an area. A peasant wants to buy a rope to…
题意: 求凸包周长. 总结: 测试模板. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define N 100005 #define eps 1e-8 using namespace std; struct point { double x, y; point(){} point(double…
[科普]什么是BestCoder?如何参加? Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8113    Accepted Submission(s): 3095 Problem Description There are a lot of trees in an area. A peasant…
先说下基础知识,不然不好理解后面的东西 两向量的X乘p1(x1,y1),p2(x2,y2) p1Xp2如果小于零则说明  p1在p2的逆时针方向 如果大于零则说明 p1在p2的顺时针方向 struct node{ double x,y; node friend operator -(node a,node b)//对减法符号进行重载 { return {a.x-b.x,a.y-b.y}; } }p[],s[]; double X(node a,node b){ return a.x*b.y-a.…
圈水池 时间限制:3000 ms  |  内存限制:65535 KB 难度:4 刚做完HDU1392,就看到这个题,嗯,原代码改改就过了. 题意不多说了,会凸包的话很简单,不会也不难,这道题时限是4s,数据100,会叉积的话三层循环遍历即可,两个点确定一条线段判断除这两个点外其他的点是否都在这条线段的一侧,是则这两个点都是凸包上的点.方法的话应该有很多,什么时候加强一下数据~~ struct node { int x,y; }p[N],a[N]; int n,tot; double dis(no…
Description Once upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals to build a beautiful brick wall with a perfec…