上一页 1 ··· 125 126 127 128 129 130 131 132 133 ··· 182 下一页
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 105#define maxl 10struct Word{ char w[maxl];}word[maxn];bool operator < (const Word &a, const Word &b){ return strcmp(a.w 阅读全文
posted @ 2011-06-21 21:18 undefined2024 阅读(348) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 1006struct Edge{ int v, next;}edge[1000005];int name[maxn];int n, ecount, tot, root;int in[maxn];int head[maxn];bool vis[maxn];bool ok;void addedge(int a, int 阅读全文
posted @ 2011-06-21 20:59 undefined2024 阅读(448) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;long long com(long long n, long long r){ if (n - r < r) r = n - r; long long i, j, s = 1; for (i = 0, j = 1; i < r; ++i) { s *= (n - i); for (; j <= r && 阅读全文
posted @ 2011-06-21 16:25 undefined2024 阅读(221) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("t.txt", "r", stdin); char ch; bool first = true; while ((ch = getchar()) != EOF) { if (ch == '"') { if (first) { pr 阅读全文
posted @ 2011-06-21 16:04 undefined2024 阅读(230) 评论(0) 推荐(0)
摘要: 题意:基本的lca问题分析:lca的离线算法为tarjan,tarjan算法的流程如下。dfs遍历树,节点a在遍历完成之后退回到a在树中的父亲节点,然后a在并查集中的father指针会指向这个父亲节点。也就是说一个节点,所有以它的被遍历过的直接子节点为根的子树中的点都会在并查集中被合并到这个点,并以它作为代表元。最开始每个点自己一个集合,每次合并操作都是伴随着遍历中的退后行为进行的。这样就产生了一个性质,在遍历过程中,一个被遍历过的节点的集合代表元在哪,取决于由树根到该节点的路径上我退后到了哪个节点。这样一来,所有遍历过的节点与当前节点的lca也恰好就是它们的代表元了。在遍历离开当前点之前,先 阅读全文
posted @ 2011-06-20 20:39 undefined2024 阅读(1491) 评论(3) 推荐(0)
上一页 1 ··· 125 126 127 128 129 130 131 132 133 ··· 182 下一页