主页
试题仓库
题目列表
试题分类
经典教材
竞赛作业
竞赛列表
提交状态
图灵学院
TuringMOOC
图灵书屋
图灵商城
图灵实验室
图灵会员
历史荣誉
支持我们
图灵IDE
用户/排名
AOJ排名
实名认证
请登录
常用链接
AOJ考试平台
老赵的Gitee代码
编译原理模拟考试平台
Java技术手册
FCC网站
菜鸟网
在线工具箱
字节豆包GPT
代码可视化
力扣网
牛客网
洛谷
杭电OJ
CodeForce
隐藏编译器
Problem 2689 --11_D : Connected Components
2689: 11_D : Connected Components
上一题
正确率: $40.00\%$
下一题
Time Limit
$1$ 秒/Second(s)
Memory Limit
$512$ 兆字节/Megabyte(s)
提交总数
$5$
正确数量
$2$
"
裁判形式
标准裁判/Standard Judge
我的状态
尚未尝试
难度
分类标签
STL
×
为本题添加算法分类(请不要超过5个)
当前分类(单击移除):
STL
单击选择分类:
Description
<p> Connected Components </p> <p> Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. </p>
Input
<p> In the first line, two integer n and m are given. n is the number of users in the SNS and m is the number of relations in the SNS. The users in the SNS are identified by IDs 0,1,...,n−1 </p> <p> In the following m lines, the relations are given. Each relation is given by two integers s and t that represents s and t are friends (and reachable each other). </p> <p> In the next line, the number of queries q is given. In the following q lines, q queries are given respectively. Each query consists of two integers s and t separated by a space character. </p>
Output
For each query, print "yes" if t is reachable from s through the social network, "no" otherwise.
Sample Input
10 9 0 1 0 2 3 4 5 7 5 6 6 7 6 8 7 8 8 9 3 0 1 5 9 1 3
Sample Output
yes yes no
提示
<p> 2≤ n≤ 100,000 </p> <p> 0≤ m≤ 100,000 </p> <p> 1≤ q≤ 10,000 </p>
推荐代码
查看2689 所有题解
上传题解视频得图灵币
本题记录
用 户(点击查看用户)
运行号(点击购买题解)
时 间
算法最快[$0 $ms]
0
内存最少[$0 $KB]
0
第一AC
0
第一挑战
0
赛题来源
会津大学《挑战数据结构与算法》
挑战数据结构与算法
AOJ
Please Login