Jack Straws

Description

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 various pairs of straws are connected by a path of touching 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.
Input

Input consist multiple case,each case consists of multiple lines. The first line will be an integer n (1 < n < 13) giving the number of straws on the table. Each of the next n lines contain 4 positive integers,x1,y1,x2 and y2, giving the coordinates, (x1,y1),(x2,y2) of the endpoints of a single straw. All coordinates will be less than 100. (Note that the straws will be of varying lengths.) The first straw entered will be known as straw #1, the second as straw #2, and so on. The remaining lines of the current case(except for the final line) will each contain two positive integers, a and b, both between 1 and n, inclusive. You are to determine if straw a can be connected to straw b. When a = 0 = b, the current case is terminated.

When n=0,the input is terminated.

There will be no illegal input and there are no zero-length straws.
Output

You should generate a line of output for each line containing a pair a and b, except the final line where a = 0 = b. The line should say simply "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

2
0 2 0 0
0 0 0 1
1 1
2 2
1 2
0 0

0
Sample Output

CONNECTED
NOT CONNECTED
CONNECTED
CONNECTED
NOT CONNECTED
CONNECTED
CONNECTED
CONNECTED
CONNECTED

1个回答

Jack Straws
-

-

Java泛型 通配符详解

GitHub开源的10个超棒后台管理面板

Java中创建对象的5种方法

100 个网络基础知识普及，看完成半个网络高手

C语言实现推箱子游戏

JVM：图文详解Java虚拟机的内存结构

Java 的每个基本类型都对应了一个包装类型，比如说 int 的包装类型为 Integer，double 的包装类型为 Double。基本类型和包装类型的区别主要有以下 4 点。
2019云栖大会高能看点之：程序员吐槽大会

python学习之路 - 从入门到精通到大师 文章目录[python学习之路 - 从入门到精通到大师](https://blog.csdn.net/TeFuirnever/article/details/90017382)1.7.回顾Python基础1.8.数据入门1.8.1.内置的原子数据类型1.8.2.内置的集合数据类型 1.7.回顾Python基础 在本节中，我们将回顾 Python 编程语...
8000字干货：那些很厉害的人是怎么构建知识体系的

Android完整知识体系路线(菜鸟-资深-大牛必进之路)

【公众号回复 “1024”，免费领取程序员赚钱实操经验】今天我章鱼猫给大家带来的这个开源项目，估计很多喜欢听音乐的朋友都会喜欢。就目前来讲，很多人对这款音乐 App 都抱...
C语言这么厉害，它自身又是用什么语言写的？

“开源（Open Source）”，这个在程序员界耳熟能详的词，几乎充斥着我们的整个职业生涯。相信没有一个程序员不知道啥是“开源”，相信没有一个程序员从来没用过“开源”产品。回顾一下，我们所熟知的一些伟大开源项目几乎都出自国外的程序大师或组织。然而，这几年国人也贡献了不少优秀的开源项目与产品，甚至有一些也收到国外同行的认可与赞许。下面我们就在一起盘点下，那些产自中国，走向世界的伟大开源项目吧！ K...