Polish version    English version  
  About Olympic -> Problems


 News
 About Olympic
About contest
Problems
I OI 1993/1994
II OI 1994/1995
III OI 1995/1996
IV OI 1996/1997
V OI 1997/1998
VI OI 1998/1999
VII OI 1999/2000
VIII OI 2000/2001
IX OI 2001/2002
X OI 2002/2003
XI OI 2003/2004
XII OI 2004/2005
XIII OI 2005/2006
XIV OI 2006/2007
XV OI 2007/2008
Problems archive
 History of OI
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
Niebieskie ksi.eczki
I Olympiad in Informatics 1993/1994

Task: TKT
Author: Piotr Chrz±stowski-Wachtel
Triangles

I stage contest  

A finite, at least three-element set A of rational length line segments is given. We want to examine whether from every three segments of A a triangle may be built.

An input data file is an at least three-element sequence of lengths of all line segments from the set A put in some order. Every segment length (a rational number) is written in a form numerator/denominator, where numerator and denominator are positive integers not greater than 9999.

Consecutive lengths in this sequence are separated by a space or a single end-of-line character.

There should be given an answer:
TAK ("yes"), if from every three line segments of A a triangle may be built.
NIE ("no"), if from not every three line segments of A a triangle may be built.
NONSENS ("nonsense"), if the data file is not correct, i.e. does not meet the above conditions.

Examples

For the input file:

13/10 1/2 6/5 11/6 9/7 3/5 9/7 13/10 9/5 8/5
the answer is NIE, because, for example, one cannot build a triangle from line segments of lengths: 6/5 3/5 9/5.

For the input file:

1/2 3/5 2/3 4/7 1/1 4/6
the answer is TAK.

For the input file:

1/2 3/5 2/3 4/7 1 4/6
the answer is NONSENS, because 1 is not a pair of numbers separated by a character /.

Task

Write a program, that successively for every data set from a file TKT.IN generates a correct answer TAK, NIE or NONSENS, and writes it to a file TKT.OUT.

The source text of the program should be written in a file named TKT.???, where ??? are substituted by a sequence of letters appropriate for the programming language used.

The executable program should be named TKT.EXE.




Print friendly version