Submit | All submissions | Best solutions | Back to list |
NOTOKNOT - Knot or Not |
Disentangling of string loops is a classical 3D-puzzle. A designer of one of these puzzles wants to know if two given string loops can be disentangled or not.
The designer says that a string loop configuration that can be disentangled is a Notknot. In fact, he says that knots are those string loops that can not be disentangled.
Your task is to write a program to help the puzzle designer deciding if some configurations can or cannot be disentangled. In the problems that you are going to solve, loops are defined by straight segments in the space between points with integer coordinates. Then, a loop is described with a list of p points with integral coordinates for some p ≥ 3.
Input
Input consists of N test cases (1 ≤ N ≤ 1000). The number N is given in the first line of the input.
Each test case contains the description of two loops, each one in a line. A description for a p points loop (3 ≤ p ≤ 20) is given in one input line with 3p integer numbers separated by blanks:
which represents the loop:
where there is a straight segment between adjacent coordinates.
Output
For each analyzed case, one line classifying the case: Notknot or Knot.
Example
Input: 3 10 0 0 0 0 -10 0 10 0 0 0 10 5 0 0 -10 -10 0 0 5 0 10 10 0 10 0 0 0 0 -10 0 10 0 0 0 10 15 0 0 -10 -10 0 0 5 0 10 10 0 1 0 0 0 1 0 0 0 1 10 10 0 0 10 0 0 0 10 10 0 0 25 5 0 3 3 0 Output: Notknot Knot Notknot
Added by: | Daniel Gómez Didier |
Date: | 2008-11-19 |
Time limit: | 4s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO |
Resource: | 2008 U.Catolica & U.Central - Circuito de maratones ACIS / REDIS |