Polish version    English version  
  History of OI -> V OI 1997/1998 -> Problems


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
Stage III - results
Stage II - results
Stage I - results
Problems
Regulations
Schedule
Stats
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
Niebieskie ksi.eczki
V Olimpiada Informatyczna 1997/1998

Task: WIE
Author: Krzysztof Diks
Polygon

I stage contest  

We say that two triangles intersect if their interiors have at least one common point. A polygon is called convex if every segment connecting any two of its points is contained in this polygon. A triangle whose vertices are also vertices of a convex polygon is called an elementary triangle of this polygon. A triangulation of a convex polygon is a set of elementary triangles of this polygon, such that no two triangles from the set intersect and a union of all triangles covers the polygon. We are given a polygon and its triangulation. What is the maximal number of triangles in this triangulation that can be intersected by an elementary triangle of this polygon?

Example
Consider the following triangulation:


The elementary triangle (1,3,5) intersects all the triangles in this triangulation.

Task
Write a program that:

  • reads the number of vertices of a polygon and its triangulation from the text file WIE.IN;
  • computes the maximal number of triangles intersected by an elementary triangle of the given polygon;
  • writes the result to the text file WIE.OUT.

Input
In the first line of the file WIE.IN there is a number n, 3<=n<=1000, which equals the number of vertices of the polygon. The vertices of the polygon are numbered from 0 to n-1 clockwise. The following n-2 lines describe the triangles in the triangulation. There are three integers separated by single spaces in the (i+1)-st line, where 1<=i<=n-2. These are the numbers of the vertices of the i-th triangle in the triangulation.

Output
In the first and only line of the file WIE.OUT there should be exactly one integer - the maximal number of triangles in the triangulation, that can be intersected by a single elementary triangle of the input polygon.

Example
For the input file WIE.IN:

6
0 1 2
2 4 3
0 5 4
2 4 0
The correct answer is the output file WIE.OUT:
4



Print friendly version