博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
05-树8 File Transfer
阅读量:5030 次
发布时间:2019-06-12

本文共 1633 字,大约阅读时间需要 5 分钟。

We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to any other?

Input Specification:

Each input file contains one test case. For each test case, the first line contains N (2), the total number of computers in a network. Each computer in the network is then represented by a positive integer between 1 and N. Then in the following lines, the input is given in the format:

I c1 c2

where I stands for inputting a connection between c1 and c2; or

C c1 c2

where C stands for checking if it is possible to transfer files between c1 and c2; or

S

where S stands for stopping this case.

Output Specification:

For each C case, print in one line the word "yes" or "no" if it is possible or impossible to transfer files between c1 and c2, respectively. At the end of each case, print in one line "The network is connected." if there is a path between any pair of computers; or "There are k components." where k is the number of connected components in this network.

Sample Input 1:

5C 3 2I 3 2C 1 5I 4 5I 2 4C 3 5S

Sample Output 1:

nonoyesThere are 2 components.

Sample Input 2:

5C 3 2I 3 2C 1 5I 4 5I 2 4C 3 5I 1 3C 1 5S

Sample Output 2:

nonoyesyesThe network is connected.

 

1 //并查集的基本操作  2 #include
3 #include
4 #define MAX 10010 5 6 int SetType[MAX]; //数组下标为结点数据,数组数据为该结点的父结点的下标 7 //根结点的数组数据为负数,其绝对值为该树的结点数目 8 9 void Init( ){10 for(int i=0; i

 

转载于:https://www.cnblogs.com/shin0324/p/9846782.html

你可能感兴趣的文章
ssh无密码登陆屌丝指南
查看>>
MySQL锁之三:MySQL的共享锁与排它锁编码演示
查看>>
docker常用命令详解
查看>>
jQuery技巧大放送
查看>>
字符串转换成JSON的三种方式
查看>>
Hive时间函数笔记
查看>>
clojure-emacs-autocomplete
查看>>
一个自己写的判断2个相同对象的属性值差异的工具类
查看>>
10 华电内部文档搜索系统 search03
查看>>
[HIHO1149]回文字符序列(dp)
查看>>
[HDU1402]A * B Problem Plus(FFT)
查看>>
[CF803C] Maximal GCD(gcd,贪心,构造)
查看>>
逆时针旋转的矩阵变换
查看>>
第10周15/16/17
查看>>
【数据库】SQL两表之间:根据一个表的字段更新另一个表的字段
查看>>
四六级作文常见错误解析(转载)
查看>>
Tomcat
查看>>
./是当前目录 ../是当前的上一级目录。上上级就是../../一般绝对路径时候常用...
查看>>
linux支持FTP和SFTP服务【1】
查看>>
树的递归与非递归遍历方法
查看>>