find的语法:find [起始目录] 寻找条件 操作find ./msg -name "*.h" -o -name "*.hpp"在当前msg目录下查找以.h或.hpp结尾的文件,这两个 -name 之间的 -o 表示逻辑或(or)
分类:
系统相关 时间:
2014-07-01 17:59:32
阅读次数:
215
First Missing Positive:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] retu...
分类:
其他好文 时间:
2014-07-01 13:13:59
阅读次数:
218
Union Find就是所谓的并查集。
本题做的很无语,最后发现居然是输入搞错,一直WA。
不能使用循环接受输入,否则是WA的,气死人,浪费那么多时间就为了这个。
难点:
1 构建关系树
2 构建公式
3 快速更新公式
要抽象思维出什么对应什么的关系和上面是逆关系,就是利用0,1,2构建出父子节点之间的关系值,我是这样去思考构建出准确无误的公式的。
这样的抽象度是挺高的,需要多多训...
分类:
其他好文 时间:
2014-07-01 11:15:20
阅读次数:
190
题目:
链接:点击打开链接
题意:
思路:
对dijkstra稍作修改即可,每次更新dis[]时改为乘积。
代码:
#include
#include
#include
using namespace std;
#define INF 100000000
const int N = 1010;
int n,m;
double map[N][N]...
分类:
其他好文 时间:
2014-07-01 10:53:50
阅读次数:
180
本题也是个标准的并查集题解。
操作完并查集之后,就是要找和0节点在同一个集合的元素有多少。
注意这个操作,需要先找到0的父母节点,然后查找有多少个节点的额父母节点和0的父母节点相同。
这个时候需要对每个节点使用find parent操作,因为最后状态的时候,节点的parent不一定是本集合的根节点。
#include
const int MAX_N = 30001;
stru...
分类:
其他好文 时间:
2014-07-01 10:50:15
阅读次数:
179
Given a string containing just the characters '(' and ')',
find the
length of the longest valid (well-formed) parentheses substring.For "(()",
the
longest valid parentheses substring is "()...
分类:
其他好文 时间:
2014-07-01 09:09:06
阅读次数:
156
题目:
链接:点击打开链接
题意:
思路:
冲突的条件是:两个人坐在同一行,同时他们到根节点的差值等于他们之间的差值,这时就产生冲突了。于是我们可以用一个dist数组来保存节点到根的距离,而这个距离在路径压缩的时候更新一下就可以了,dist[x]+=dist[parent[x]]。然后就是合并后的距离,令r1=Find(u),r2=Fin...
分类:
其他好文 时间:
2014-07-01 08:13:34
阅读次数:
201
本题是标准的并查集了,最后利用这些集求有多少独立集。
所以这里也写个标准程序过了。
最后查找独立集合: 看有多少个节点的父母节点是自己的,那么就是独立集合了。自己做自己的父母当然最独立的了,没有任何依赖,呵呵。
#include
const int MAX_N = 50001;
//const int MAX_M = MAX_N/2 * (MAX_N-1) + 1;
int N, M;
...
分类:
其他好文 时间:
2014-07-01 07:46:53
阅读次数:
160
题目
Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it witho...
分类:
其他好文 时间:
2014-07-01 06:24:42
阅读次数:
204
题目
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it...
分类:
其他好文 时间:
2014-07-01 06:23:24
阅读次数:
334