Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or ...
分类:
其他好文 时间:
2016-08-27 09:51:17
阅读次数:
140
LCA(最近公共祖先) 在有根树中,找出某两个结点u和v最近的公共祖先(或者说,离树根最远的公共祖先)。
类似于这样来访问 ......
每次修改的时候直接修改就行
1e18 -> 2^63次所以每次 2*63*q == 1e5
复杂度 O(2*63*n)
此外对于 map<pair, LL> mpt;//map tree
和 map<LL, map > mpt;//map tree
前面用 Codeforces上的数据做了测试, 这两种写法时间上是差不多的, 然而在空间...
分类:
其他好文 时间:
2016-08-24 01:09:56
阅读次数:
146
MongoDB是文档型数据库,有一些专门的术语,和关系型DB相似,但也有差异,例如,Collection类似于关系型DB的Table,document类似于row,key/value pair类似于column。document 是使用{}为边界,一个Key/Value对使用“:”分割,key/va ...
分类:
数据库 时间:
2016-08-22 18:17:31
阅读次数:
252
解析:平面上的点分治,先递归得到左右子区间的最小值d,再处理改区间,肯定不会考虑哪些距离已经大于d的点对,对y坐标归并排序,然后从小到大开始枚举更新d,对于某个点,x轴方向只用考虑[x-d,x+d](x是分的中轴线),y轴方向只用考虑[y-d,y](y是这个点的y值),因为d值一直在变小,所以这个矩 ...
分类:
其他好文 时间:
2016-08-21 19:54:09
阅读次数:
261
SPFA在求最短路时不是万能的。在稠密图时用堆优化的dijkstra更加高效: 1 typedef pair<int,int> pii; 2 priority_queue<pii, vector<pii>, greater<pii> > q 3 void dijkstra(){ 4 memset(d ...
分类:
其他好文 时间:
2016-08-21 15:20:57
阅读次数:
265
Nested Segments Time limit: 1.0 secondMemory limit: 64 MB You are given n segments on a straight line. For each pair of segments it is known that they ...
分类:
其他好文 时间:
2016-08-19 13:03:58
阅读次数:
153
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected ...
分类:
其他好文 时间:
2016-08-19 07:29:23
阅读次数:
115
ZYB has a premutation P,but he only remeber the reverse log of each prefix of the premutation,now he ask you to restore the premutation. Pair (i, j)(i ...
分类:
其他好文 时间:
2016-08-16 16:00:12
阅读次数:
187
比赛题目链接 题意:有n个人每人拿着一把枪想要杀死n个怪兽,大写字母代表人,小写字母代表怪兽。A只能杀死a,B只能杀死b,如题目中的图所示,枪的弹道不能交叉。人和怪兽的编号分别是1到n,问是否存在能全部杀死的情况,如果存在则输出编号1到n的每个人杀死的怪兽的编号,如果不能输出"Impossible" ...
分类:
其他好文 时间:
2016-08-13 21:12:32
阅读次数:
190
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected ...
分类:
其他好文 时间:
2016-08-12 15:01:03
阅读次数:
117