poj 3246 Game
Time Limit: 4000MS | Memory Limit: 65536K | |
Total Submissions: 2707 | Accepted: 488 |
Description
Wintokk likes playing games on convex-hull. One day, Dragon wants to test him.
Dragon has drawn N points on a plane with no points in the same place. Dragon wants to know the smallest of the N convex-hulls formed by removing exactly one point from the N points.
But Wintokk is so stupid. Can you help him find the smallest area after removing a single point?
Input
The input contains several test cases.
Each test starts with an integer N(4 ≤ N < 105+1), the total number of points on the plane.
The next N lines, each contains two integers x and y, indicating the position of the point.
The input ends up with N=0.
Output
Output the smallest area with two digits after the decimal point.
Sample Input
4
1 0
0 0
0 1
1 1
0
Sample Output
0.50 翻译:给定平面上N个点,现在从中去掉一个点,去掉后使得剩余的点所构成的凸包的面积达到最小值,求这个最小值。
思路:直接穷举水过。
AC代码:
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<string>
#include<queue>
#include<cstring>
#include<cstdio>
#include <climits>
using namespace std;
#define INF 0x3f3f3f3f
const int N_MAX = + ;
int N;
struct P {
int x, y,id;
P() {}
P(int x, int y) :x(x),y(y){}
P operator +(P p) {
return P(x + p.x, y + p.y);
}
P operator -(P p) {
return P(x - p.x, y - p.y);
}
P operator *(int d) {
return P(x*d, y*d);
}
int dot(P p) {
return x*p.x+y*p.y;
}
int det(P p) {
return x*p.y - y*p.x;
}
int norm() {
return x*x + y*y;
}
bool operator < (const P& b)const{
if (x != b.x)return x < b.x;
return y < b.y;
} };
P p[N_MAX],tmp[N_MAX];
struct Segment{
P p1, p2;
Segment(P p1,P p2):p1(p1),p2(p2) {}
};
typedef Segment Line; int GetArea(Segment l ,P p) {//计算直线l和点P所构成的平行四边形面积
return abs((l.p2 - l.p1).det(p - l.p1));
} vector<P>convex_hull(P*ps, int n) {
sort(ps, ps + n);
int k = ;
vector<P>qs( * n);
for (int i = ; i < n;i++) {
while (k > && (qs[k - ] - qs[k - ]).det(ps[i] - qs[k - ]) <= ) k--;
qs[k++] = ps[i];
}
for (int i = n - , t = k; i >= ;i--) {
while (k > t && (qs[k - ] - qs[k - ]).det(ps[i] - qs[k - ]) <= )k--;
qs[k++] = ps[i];
}
qs.resize(k-);
return qs;
}
typedef vector<P> Polygon; int GetArea_convexhull(Polygon ps) {//计算凸多边形面积
int sum = ; for (int i = ; i < ps.size();i++) {
P p1 = ps[i], p2 = ps[i-];
Segment l = Segment(p1, p2);
sum += GetArea(l, ps[]);
}
return sum;
} int main() {
while (scanf("%d",&N)&&N) {
for (int i = ; i < N;i++) {
scanf("%d%d",&p[i].x,&p[i].y);
p[i].id = i;
}
memcpy(tmp, p, sizeof(p));
int sum_max = INT_MAX;
Polygon ps = convex_hull(p, N);//要去除的点一定在凸包上
for (int i = ; i < ps.size();i++) {
memcpy(p, tmp, sizeof(tmp));
swap(p[ps[i].id], p[N - ]);//将第i个凸包上的点去除
int sum=GetArea_convexhull(convex_hull(p, N - ));
sum_max =min(sum_max, sum);
}
printf("%d%s\n",sum_max/,(sum_max&)?".50":".00");
}
return ;
}
poj 3246 Game的更多相关文章
- POJ 3246 Game(凸包)
[题目链接] http://poj.org/problem?id=3246 [题目大意] 给出一些点,请删去一个点,使得包围这些点用的线长最短 [题解] 去掉的点肯定是凸包上的点,所以枚举凸包上的点去 ...
- Poj 3246 Balanced Lineup(线段树基础)
依旧是线段树基础题 询问区间的最大值和最小值之差,只有询问,没有插入删除.继续理解基础线段树 #include <iostream> #include <algorithm> ...
- poj 3246 Balanced Lineup(线段树)
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 38942 Accepted: 18247 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
随机推荐
- spring5之SAXParseException:cvc-elt.1: 找不到元素 “beans” 的声明
之前SSM项目一直报错,就是找不到错误 气啊 后来在网上找到了答案:燕来spring5之后就不再需要写版本号了
- Python——函数入门(一)
一.理解函数 举一个例子,当我们需要重复使用一个功能的时候,不可能每次都去复制一次代码,这个时候就需要用到函数了,所谓的函数,简单来说就是给函数取一个名字,当需要用到这个功能的时候,就可以通过这个名字 ...
- java基础—java制作证书的工具keytool
一.keytool的概念 keytool 是个密钥和证书管理工具.它使用户能够管理自己的公钥/私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户/服务认证自己)或数据完整性以及认证服务.在 ...
- mysql crash cource 书中实例
样例表 CREATE TABLE customers( cust_id int NOT NULL AUTO_INCREMENT, cust_name char(50) ...
- SVN:The working copy is locked due to a previous error (一)
使用 Cornerstone 时,碰到如题问题,SVN无法Update.Commit等操作. 解决办法:Working Copies ⟹ '右键' ⟹ Clean 即可解决! 尊重作者劳动成果,转载 ...
- C# 使用Epplus导出Excel [4]:合并指定行
C# 使用Epplus导出Excel [1]:导出固定列数据 C# 使用Epplus导出Excel [2]:导出动态列数据 C# 使用Epplus导出Excel [3]:合并列连续相同数据 C# 使用 ...
- GoogleTest 之路1-Generic Build Instructions编译指导总方案
准备工作 为了在你的测试中使用GoogleTest, 你必须让你的编译系统 知道到哪里去寻找GoogleTest 的头文件和源文件. 具体的方法只能依赖于你具体使用的哪种编译系统了,一般来讲这个非常容 ...
- pandas处理较大数据量级的方法 - chunk,hdf,pkl
前情提要: 工作原因需要处理一批约30G左右的CSV数据,数据量级不需要hadoop的使用,同时由于办公的本本内存较低的缘故,需要解读取数据时内存不足的原因. 操作流程: 方法与方式:首先是读取数据, ...
- (转).gitignore详解
本文转自http://sentsin.com/web/666.html 今天讲讲Git中非常重要的一个文件——.gitignore. 首先要强调一点,这个文件的完整文件名就是“.gitignore”, ...
- ax=1(%b) 求最小逆元
定理一:如果d = gcd(a, b),则必能找到正的或负的整数x和y,使 d = a*x+ b*y. 定理二:若gcd(a, b) = ,则方程ax ≡ c (mod b)在[, b-]上有唯一解. ...