上一页 1 ··· 10 11 12 13 14
  2011年7月23日
摘要: poj 2524并查集基础题,但是由于刚开始不熟悉,还是错了好几次题目大意:有学生学号1--n,给你一些学生之间的关系,即属于同一宗教的学生, 找出共有多少不同的宗教数解决:就是一个并查集的最基础题目,写个并查集就过了#include <stdio.h>#include <string.h>int num[50005];int n,m;int find(int x)//查找{ if(num[x]<0)return x; return num[x]=find(num[x]);}void merge(int a,int b)//合并{//就是因为对合并算法不熟悉,导致 阅读全文
posted @ 2011-07-23 17:01 猿类的进化史 阅读(221) 评论(0) 推荐(0) 编辑
摘要: poj 1308题目大意:判断给定的数对是否构成一棵树,解决:并查集 1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 int num[10005]; 5 bool outdegree[10005]; 6 bool mark[10005];//标记该结点是树的一个结点 7 int find(int x)//并查集的查找 8 { 9 if(num[x]<0)return x;10 return num[x]=find(num[x]);11 }12 bool merge(int a, 阅读全文
posted @ 2011-07-23 08:48 猿类的进化史 阅读(192) 评论(0) 推荐(0) 编辑
  2011年4月22日
摘要: 阅读全文
posted @ 2011-04-22 18:16 猿类的进化史 阅读(137) 评论(0) 推荐(0) 编辑
摘要: for_each 1 //对序列中的每个元素执行某操作 for_each() 2 /*template<class InputIterator, class Function> 3 Function for_each(InputIterator first, InputIterator last, Function f) 4 { 5 for ( ; first!=last; ++first ) f(*first); 6 return f; 7 }*/ 8 #include<iostream> 9 #include <vector>10 using names 阅读全文
posted @ 2011-04-22 15:09 猿类的进化史 阅读(191) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14