当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1439:Rhombs

题目描述
An unbounded triangular grid is a plane covered by equilateral triangles:

Two neighboring triangles in the grid form a rhomb. There are 3 types of such rhombs:

A grid polygon is a simple polygon which sides consist entirely of sides of triangles in the grid. We say that a grid polygon is rhombastic if it can be partitioned into internally disjoint rhombs of types A, B and C.

As an example let's consider the following grid hexagon:

This hexagon can be partitioned into 4 rhombs of type A, 4 rhombs of type B and 4 rhombs of type C:

For a given rhombastic grid polygon P compute the numbers of rhombs of types A, B and C in some correct partition.

Write a program that:

  • reads a description of a rhombastic grid polygon from the standard input,

  • computes the numbers of rhombs of types A, B and C in some correct partition of the polygon,

  • writes the results to the standard output.
输入解释
The first line of the input contains an integer n (3 <= n <= 50 000) - the number of sides of a rhombastic grid polygon. Each of the next n lines contains a description of one side of the polygon. The sides are given one by one in the clockwise order. No two consecutive sides of the polygon lie on the same straight line. The description of a side consists of two integers d and k. Integer d says what is the direction of the side according to the following figure:

Integer k is the length of the polygon side measured in the number of sides of grid triangles. Sum of all numbers k is not larger than 100 000.

Process to the end of file.
输出解释
The first and only line of the output contains three integers separated by single spaces denoting the number of rhombs of type A, B and C respectively, in some partition of the input polygon.
输入样例
6
1 2
2 2
3 2
4 2
5 2
6 2
输出样例
4 4 4

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Central Europe 2002

源链接: POJ-1439

最后修改于 2020-10-29T06:04:09+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000