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的更多相关文章

  1. POJ 3246 Game(凸包)

    [题目链接] http://poj.org/problem?id=3246 [题目大意] 给出一些点,请删去一个点,使得包围这些点用的线长最短 [题解] 去掉的点肯定是凸包上的点,所以枚举凸包上的点去 ...

  2. Poj 3246 Balanced Lineup(线段树基础)

    依旧是线段树基础题 询问区间的最大值和最小值之差,只有询问,没有插入删除.继续理解基础线段树 #include <iostream> #include <algorithm> ...

  3. poj 3246 Balanced Lineup(线段树)

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 38942   Accepted: 18247 ...

  4. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  5. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  6. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  7. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  8. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  9. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

随机推荐

  1. Google「Game Builder」:不懂编程,也能开发 3D 游戏

    简评: 之前微软曾推出过「Kodu Game Lab」,它可以让完全没有编程经验的人通过简单的步骤打造属于自己的游戏.无独有偶,Google 最近在 Steam 也推出了类似的程序「Game Buil ...

  2. Bootstrap历练实例:默认的Well

    Well 是一种会引起内容凹陷显示或插图效果的容器 <div>.为了创建 Well,只需要简单地把内容放在带有 class .well 的 <div> 中即可.下面的实例演示了 ...

  3. Tomcat详细安装配置

    1.首先是Tomcat的获取和安装. 获取当然得上Apache的官方网站下载,开源免费,而且带宽也足够.下载会很快. 这是两种不同的下载,一个是普通安装版本,一个是解压安装版本.使用起来是一样的,只是 ...

  4. datatable css not work

    样式不显示问题 无论是放内联样式文件还是直接放HTML文件都不显示 后来发现是因为datatable是放在后面初始化,它自带的样式覆盖了我们自定义的样式 所以要注意写code时,很多时候不是code不 ...

  5. 使用 CFile 的子类 CStdioFile 的注意事项

    目前为止只用到了 ReadString,也了解了一下 WriteString. 由于程序需要,本来程序中是用的CFile, 但是需要逐行读取文件数据,所以谷歌找到了 ReadString 类 —— 继 ...

  6. CF #552 div3

    A - Restoring Three Numbers CodeForces - 1154A Polycarp has guessed three positive integers aa, bb a ...

  7. java--String、StringBuilder、StringBuffer的解析和比较?

    一.String的解析 1.String的含义 ①String是不可以被继承的,String类是final类,String类是由char[]数组来存储字符串. ②String是不可变的字符序列,如果存 ...

  8. 在WIN2008R2的IIS7环境下安装PHP5.6.15

    1.下载PHP5.6.15 在http://windows.php.net/download页面中找到VC11 x64 Non Thread Safe下载ZIP版. 2.将下载的压缩包解压到D盘PHP ...

  9. Divisibility by 25 CodeForces - 988E

    You are given an integer nn from 11 to 10181018 without leading zeroes. In one move you can swap any ...

  10. npm 安装express npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE

    npm安装总是报错 报错信息: 解决方案: 在命令行输入: npm config set strict-ssl false 设置之后即可安装软件: