Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43274   Accepted: 14716 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 w…
LINK 题意:给出一个简单几何,问与其边距离长为L的几何图形的周长. 思路:求一个几何图形的最小外接几何,就是求凸包,距离为L相当于再多增加上一个圆的周长(因为只有四个角).看了黑书使用graham算法极角序求凸包会有点小问题,最好用水平序比较好.或者用Melkman算法 /** @Date : 2017-07-13 14:17:05 * @FileName: POJ 1113 极角序求凸包 基础凸包.cpp * @Platform: Windows * @Author : Lweleth (…
题目链接:poj 1113   单调链凸包小结 题解:本题用到的依然是凸包来求,最短的周长,只是多加了一个圆的长度而已,套用模板,就能搞定: AC代码: #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> using namespace std; int m,n; struct p { double x,y; friend int operator <(p a,…
Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26286   Accepted: 8760 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 wo…
此题为凸包问题模板题,题目中所给点均为整点,考虑到数据范围问题求norm()时先转换成double了,把norm()那句改成<vector>压栈即可求得凸包. 初次提交被坑得很惨,在GDB中可以完美运行A掉,到OJ上就频频RE(此处应有黑人问号) 后来发现了问题,原因是玩杂耍写了这样的代码 struct point { int x, y; point (){ scanf("%d%d", &x, &y); } ... }pt[MAXN]; 于是乎,在swap…
题意 题目链接 给出平面上n个点的坐标.你需要建一个围墙,把所有的点围在里面,且围墙距所有点的距离不小于l.求围墙的最小长度. \(n \leqslant 10^5\) Sol 首先考虑如果没有l的限制,那么显然就是凸包的长度. 现在了距离的限制,那么显然原来建在凸包上的围墙要向外移动\(l\)的距离,同时会增加一些没有围住的位置 因为多边形的外交和为360,再根据补角的性质,画一画图就知道这一块是一个半径为\(l\)的圆. 因为总答案为凸包周长 + \(2 \pi l\) #include<c…
A Plug for UNIX Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15597   Accepted: 5308 Description You are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an int…
Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28462   Accepted: 9498 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 wo…
Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31199   Accepted: 10521 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 w…
http://poj.org/problem?id=1113 不多说...凸包网上解法很多,这个是用graham的极角排序,也就是算导上的那个解法 其实其他方法随便乱搞都行...我只是测一下模板... struct POINT{ double x,y; POINT(, ):x(_x),y(_y){}; }; POINT p[MAXN],s[MAXN]; double dist(POINT p1,POINT p2){ return(sqrt((p1.x-p2.x) * (p1.x-p2.x) +…
题目链接 题意 : 求凸包周长+一个完整的圆周长. 因为走一圈,经过拐点时,所形成的扇形的内角和是360度,故一个完整的圆. 思路 : 求出凸包来,然后加上圆的周长 #include <stdio.h> #include <string.h> #include <iostream> #include <cmath> #include <algorithm> const double PI = acos(-1.0) ; using namespac…
Wall Time Limit: 1000MS Memory Limit: 10000K 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…
题目: http://poj.org/problem?id=1113 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#problem/F Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26219   Accepted: 8738 Description Once upon a time there was a greedy King who…
[题目链接] http://poj.org/problem?id=1113 [题目大意] 给出一个城堡,要求求出距城堡距离大于L的地方建围墙将城堡围起来求所要围墙的长度 [题解] 画图易得答案为凸包的周长加一个圆的周长. [代码] #include <cstdio> #include <algorithm> #include <cmath> #include <vector> using namespace std; double EPS=1e-10; co…
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…
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…
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…
题目传送门 题意:求最短路线,使得线上任意一点离城堡至少L距离 分析:先求凸包,答案 = 凸包的长度 + 以L为半径的圆的周长 /************************************************ * Author :Running_Time * Created Time :2015/10/25 11:00:48 * File Name :POJ_1113.cpp ************************************************/ #…
题链: http://poj.org/problem?id=1113 题解: 计算几何,凸包 题意:修一圈围墙把给出的点包围起来,且被包围的点距离围墙的距离不能小于L,求围墙最短为多少. 答案其实就是等于N个点的凸包的周长+半径为L的圆的周长. 代码: #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define…
题目链接:http://poj.org/problem?id=1113 题目大意:给出点集和一个长度L,要求用最短长度的围墙把所有点集围住,并且围墙每一处距离所有点的距离最少为L,求围墙的长度. 解法:凸包+以L为半径的圆的周长.以题目中的图为例,两点之间的围墙长度之和正好就是凸包的长度,再加上每个点的拐角处(注意此处为弧,才能保证城墙距离点的距离最短)的长度. #include<iostream> #include<cstdio> #include<cstdlib>…
1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #include<cstdio> #include<cstdlib> #define F(i,a,b) f…
Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.Farmer John ordered a high speed connection for his farm and is going to share his…
题目: 给几个点,用绳子圈出最大的面积养牛,输出最大面积/50 题解: Graham凸包算法的模板题 下面给出做法 1.选出x坐标最小(相同情况y最小)的点作为极点(显然他一定在凸包上) 2.其他点进行极角排序<极角指从坐标轴的某一方向逆时针旋转到向量的角度>, 极角一样按距离从近到远(可以用叉积实现) 3.用栈维护凸包上的点,将极点和极角序最小的点依次入栈 4.按顺序扫描,检查栈顶的前两个元素与这个点构成的线段是否拐向右(顺时针侧,叉积小于0) 如果满足就弹出栈顶元素,直到不满足或者栈里不足…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5646   Accepted: 1226 Description In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p: ⊕ is the xor operator. We say a path the xor-l…
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define maxn 1005 using namespace std; ]; int n,q,T,l,r; void ST(){ ;i<=n;i++) mx[i][]=a[i]; ;(<<j)<=n;j++) ;i+(<<j)-<=n;i++) mx[i][j]=m…
Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description There are a lot of trees in an area. A peasant wants to buy a rope to surround all these trees. So at first he must know the mi…
//极角排序 #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…
题目大意: 在一个序列上每次改动一个值,然后求出它的最大的子序列和. 思路分析: 首先我们不考虑不成环的问题.那就是直接求每一个区间的最大值就好了. 可是此处成环,那么看一下以下例子. 5 1 -2 -3 4 5 那么你会发现 max = sum - min 也就是和减去最小区间和也能够得到. 所以我们最后要得到的就是两个东西.注意题目中说的不能所有取得.所以还要推断一下max 是不是等于 sum的. #include <cstdio> #include <iostream> #i…
题意:给定N,M,然后给出M组信息(u,v,l,r),表示u到v有[l,r]范围的通行证有效.问有多少种通行证可以使得1和N连通. 思路:和bzoj魔法森林有点像,LCT维护最小生成树.  开始和队友在想维护连通性,而不是维护树,这样好像会很麻烦. 队友yy了一个算法:用线段树模拟并查集维护连通性.(发现和标程有点像? 我的代码:LCT维护最小生成树. ...先给代码,后面补一下题解. #include<bits/stdc++.h> #define ll long long using nam…
Wall Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3139    Accepted Submission(s): 888 Problem Description Once upon a time there was a greedy King who ordered his chief Architect to build a w…