-->
当前位置:首页 > 题库

PROGRAMMING:file transfer

Luz5年前 (2021-05-10)题库467
When two computers are connected in two directions, files can be transferred between two computers. Given a set of computer network, can you determine whether any two specified computers can transfer files?
###Input format:
First, in the first line, we give the total number of computers in the network $$n $($$2 / Le n / Le 10 ^ 4 $$), so we assume that these computers are numbered from 1 to $$n $$. Each line of input is then given in the following format:
```
I c1 c2
```
Where 'I' means to connect computers' C1 'and' C2 '; Or is it
```
C c1 c2
```
Where 'C' means to query whether files can be transferred between 'C1' and 'C2'; Or is it
```
S
```
Here's' means that the input is terminated.
###Output format:
For each query starting with 'C', if files can be transferred between 'C1' and 'C2', output "yes" in one line, otherwise output "no". When the terminator is read, output "the network is connected" in one line if all computers in the network can transfer files; Or output "there are 'k' components." where 'k' is the number of connected sets in the network.
###Input sample 1:
```in
five
C 3 2
I 3 2
C 1 5
I 4 5
I 2 4
C 3 5
S
```
###Output sample 1:
```out
no
no
yes
There are 2 components.
```
###Input example 2:
```in
five
C 3 2
I 3 2
C 1 5
I 4 5
I 2 4
C 3 5
I 1 3
C 1 5
S
```
###Output example 2:
```out
no
no
yes
yes
The network is connected.
```







answer:If there is no answer, please comment