P2924 [USACO08DEC]大栅栏Largest Fence

    • 59通过
    • 113提交
  • 题目提供者 FarmerJohn2
  • 评测方式 云端评测
  • 标签 凸包 数论,数学 素数判断,质数,筛法 USACO 2008 高性能
  • 难度 省选/NOI-
  • 时空限制 1000ms / 128MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题目描述

    Farmer John has purchased N (5 <= N <= 250) fence posts in order to build a very nice-looking fence. Everyone knows the best fences are convex polygons where fence posts form vertices of a polygon. The pasture is represented as a rectilinear grid; fencepost i is at integer coordinates (x_i, y_i) (1 <= x_i <= 1,000; 1 <= y_i <= 1000).

    Given the locations of N fence posts (which, intriguingly, feature no set of three points which are collinear), what is the largest number of fence posts FJ can use to create a fence that is convex?

    For test cases worth 45% of the points for this problem, N <= 65.

    Time limit: 1.2 seconds

    POINTS: 400

    Farmer John的农场里有N(5<=N<=250)个篱笆桩,每个都有独一无二的坐标(xi,yi)(1<=xi,yi<=1000)。他想选择尽量多的篱笆桩来构建他的围栏。这个围栏要美观,所以必须是凸多边形的。那他最多能选多少个呢?

    所有的篱笆桩中不存在三点共线。

    输入输出格式

    输入格式:

    * Line 1: A single integer: N

    * Lines 2..N+1: Line i+1 describes fence post i's location with two space-separated integers: x_i and y_i

    输出格式:

    * Line 1: A single integer, the maximum possible number of fence posts that form a convex polygon.

    输入输出样例

    输入样例#1: 复制
    6 
    5 5 
    2 3 
    3 2 
    1 5 
    5 1 
    1 1 
    
    输出样例#1: 复制
    5 
    

    说明

    A square with two points inside.

    The largest convex polygon is the pentagon (2,3), (3,2), (5,1), (5,5), (1,5).

    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。