There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct... ...
分类:
其他好文 时间:
2018-01-07 14:03:24
阅读次数:
152
原题链接在这里:https://leetcode.com/problems/friend-circles/description/ 题目: There are N students in a class. Some of them are friends, while some are not. T ...
分类:
其他好文 时间:
2018-01-01 11:32:59
阅读次数:
128
返回共同好友最多的K个好友推荐input: Personreturn Listclass person{String id;Set friends;} 用pq 更快些 ...
分类:
其他好文 时间:
2017-12-30 12:25:57
阅读次数:
114
https://www.luogu.org/problemnew/show/1456 题目描述 Once in a forest, there lived N aggressive monkeys. At the beginning, they each does things in its own ...
分类:
其他好文 时间:
2017-12-29 19:01:56
阅读次数:
172
如下,我们已经有了一个从Contact类继承过来的Friend类 如果要给Friend类增加一个住址的方法,住址信息包括街道、城市、国家等。我们可以把这些字符串直接传递给Friend中的__init__方法,另外也可以把这些字符串先存放在一个元组或者字典里面,然后再把他作为单一的参数传递给__ini ...
分类:
编程语言 时间:
2017-12-29 15:30:02
阅读次数:
290
友元函数: 友元函数是一种 1.定义在类外, 2.但是可以访问类域中的私有和保护成员。 即便友元函数的原型出现在类定义中,友元函数并不是成员函数,这一点尤其需要注意。 友元可以是函数、函数模版、成员函数;或者所有成员都是友元的类或类模版。 所以不要局限对友元的理解。 声明一个类的友元函数,只需要加上 ...
分类:
其他好文 时间:
2017-12-22 21:48:29
阅读次数:
145
定义了A类的时候,需要定义一个B类来完善A的功能,A类当中有 返回类型为B的函数 ,定义A之前,先声明了B,且B作为A的友元,需要访问A的私有成员。 eg: class B; class A { public: friend class B; A(); B fun1() {return B(*thi ...
分类:
其他好文 时间:
2017-12-21 23:04:42
阅读次数:
320
题目描述 DD wants to send a gift to his best friend CC as her birthday is coming. However, he can’t afford expensive gifts, and he is so lazy that he is n ...
分类:
其他好文 时间:
2017-12-21 16:00:40
阅读次数:
137
A. Visiting a Friend 水题,但是需要注意段点初,及最后的位置 代码如下: B. Coloring a Tree 额。。。也挺水的,dfs或bfs即可,起点任意一点即可 代码如下: C. Hashing Trees 找到规律,发现当a[i]>1&&a[i-1]>1是该树会出现异构, ...
分类:
其他好文 时间:
2017-12-21 01:56:04
阅读次数:
192
https://www.codechef.com/DEC17/problems/GIT01 All submissions for this problem are available. Read problems statements in Mandarin chinese, Russian an ...
分类:
其他好文 时间:
2017-12-19 00:51:16
阅读次数:
200