编程介的小学生 2016-12-05 08:17 采纳率: 20.5%
浏览 1038
已采纳

Find the Border

Description

Closed polyline (with possible self-intersections) partitions a plane into a number of regions. One of the regions is unbounded -- it is an exterior of the polyline. All the bounded regions together with the polyline itself form an interior of the polyline (shaded in the picture below). The border of the interior (bold line in the picture) is a polyline as well. This polyline has the same interior as the original one.
Your task is to find the border of the interior of the given polyline.


To guarantee the uniqueness (up to the starting point) of the polyline representing the border we require that the following conditions are satisfied for it:
it has no self-intersections, although may have self-touchings;
no adjacent vertices of the border coincide;
no adjacent edges of the border are collinear;
when traversing the border, its interior is always to the left of its edges.

Input

The first line of the input file contains an integer number n (3 <= n <= 100) -- the number of vertices in the original polyline. Following n lines contain two integer numbers xi and yi on a line (0 <= xi, yi <= 100) -- coordinates of the vertices. All vertices are different and no vertex lies on an edge between two other vertices. Adjacent edges of the polyline are not collinear.
Output

Write to the output file an integer number m -- the number of vertices of the border. Then write m lines with coordinates of the vertices. Coordinates must be precise up to 4 digits after the decimal point.
Sample Input

10
4 9
9 9
12 4
10 2
9 5
14 10
14 5
10 9
11 4
4 4
Sample Output

13
9.3333 4
10 2
12 4
10.5 6.5
11.5 7.5
14 5
14 10
11.5 7.5
10 9
10.5 6.5
9 9
4 9
4 4

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-12-13 13:14
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)