Programming contests

ACM ICPC programozó csapatverseny, házi forduló, 2012. október 7.

October 7, 2012 10:15 AM – October 7, 2012 3:15 PM

The Lazy Lumberjacks

Once upon a time in a far, far away forest, there was a team of lazy lumberjacks. Since they were too lazy to cut trees, they were always figuring out ways to sneak out of work. Their foreman, on the other side, was always trying to put them all to work.

After a lot of discussions, the foreman and the lumberjacks came to an agreement: they will work, but only if the area of the forest assigned to each one was a triangle. If it was any other shape, they will be free not to work that week. The idea was to give each lumberjack three numbers representing the lengths of each of the triangles' sides. If the numbers were correct and form a triangle, the lumberjacks had to work, else they were free to leave and not work.

Since our lumberjacks are as cunning as they are lazy, they convince the foreman to let them determine the surface and the site in the forest where they will work. As a result, the lumberjacks keep passing the foreman sets of numbers that could not form the sides of a triangle. After a while, the foreman began to suspect and decided to write a program that validates the input of each lumberjack. Now, when the lumberjacks decide to pass wrong numbers, they get a fine of $1000.00 (more than a day's salary).

Your job is to write the program that the foreman has to use to determine if the numbers (all integers) passed by the lumberjacks can be the sides of a triangle. If they can, you have to print “OK”, else you have to print “Wrong!!

Input Specification

The input consists of a data set describing the numbers that each lumberjack has passed to the foreman for the day. The data is formatted as follows: The first line is an integer N (2 ≤ N ≤ 20). Then follows N lines, each one containing three integers separated by a space. All integers are between -109 and 109.

Output Specification

For each line in the input, you have to find if the integers can represent the sides of a triangle. If they can, you have to print “OK”, else you have to print “Wrong!!” for each line in the input.

Sample Input

  1. 6
  2. 1 2 3
  3. 3 2 5
  4. 3 4 5
  5. 6 6 1
  6. 3 3 3
  7. 7 3 10
download as text file

Output for Sample Input

  1. Wrong!!
  2. Wrong!!
  3. OK
  4. OK
  5. OK
  6. Wrong!!
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019