Program | STRAWS.C, STRAWS.CPP, STRAWS.PAS |
In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned with if a path of touching straws connects various pairs of straws. You will be given a list of the endpoints for some straws (as if they were dumped on a large piece of graph paper) and then will be asked if various pairs of straws are connected. Note that touching is connecting, but also two straws can be connected indirectly via other connected straws.
CONNECTED
",
if straw a is connected to straw b, or "NOT CONNECTED
",
if straw a is not connected to straw b. For our purposes, a straw is considered
connected to itself.
Sample Input:
7
1 6 3 3
4 6 4 9
4 5 6 7
1 4 3 5
3 5 5 5
5 2 6 3
5 4 7 2
1 4
1 6
3 3
6 7
2 3
1 3
0 0
Sample Output:
CONNECTED
NOT CONNECTED
CONNECTED
CONNECTED
NOT CONNECTED
CONNECTED