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 题目连接: 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…
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…
题意:如果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…
食物链 总时间限制: 1000ms 内存限制: 65536kB 描述 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类. 第二种说法是"2 X Y",表示X吃Y. 此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话…
题目大意:给定一张无向图,要求如果 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…