题意:如果1认识2,2认识3,必须要求有:1认识3.如果满足上述条件,输出YES,否则输出NO. 思路:显然如果是一个完全图就输出YES,否则就输出NO,如果是无向完全图则一定有我们可以用dfs来书边和点 n个节点的有向完全图边数为e=n*(n-1) 代码: #include <bits/stdc++.h> #define maxn 150000 #define ll long long using namespace std; vector <]; ]; int t; void dfs…
B. Bear and Friendship Condition time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Bear Limak examines a social network. Its main functionality is that two members can become friends (then th…
B. Bear and Friendship Condition 题目连接: http://codeforces.com/contest/791/problem/B Description Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pic…
B. Bear and Friendship Condition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bear Limak examines a social network. Its main functionality is that two members can become friends (then th…
B. Bear and Friendship Condition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bear Limak examines a social network. Its main functionality is that two members can become friends (then th…
B. Bear and Friendship Condition time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Bear Limak examines a social network. Its main functionality is that two members can become friends (then th…
B. Bear and Friendship Condition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bear Limak examines a social network. Its main functionality is that two members can become friends (then th…
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures). There are n members, numbered 1 through n. m pairs of members are friends. Of course, a…
题目大意:给定一张无向图,要求如果 A 与 B 之间有边,B 与 C 之间有边,那么 A 与 C 之间也需要有边.问这张图是否满足要求. 题解:根据以上性质,即:A 与 B 有关系,B 与 C 有关系,那么 A 和 C 也要有关系,因此可以采用并查集加以维护,维护关系的同时顺便维护各个联通块的大小,若符合题目要求,则同一个联通块中的点必须均有关系.因此,最后计算一下每个联通块的应有关系数和最初所给的关系数比较,相等则符合,反之,不符合. 代码如下 #include <bits/stdc++.h>…
[题目链接]:http://codeforces.com/contest/791/problem/B [题意] 给你m对朋友关系; 如果x-y是朋友,y-z是朋友 要求x-z也是朋友. 问你所给的图是否符合 [题解] 用并查集处理出每个朋友"团"的大小->就是连通块 然后这个连通块里面应该要有x*(x-1)/2条边; 按照这个规则,求出应该有的边数; 然后和所给的m对比; 相同则YES,否则NO [完整代码] #include <bits/stdc++.h> usin…