摘要:
1 //只需要判断入度为零的点是不是只有1个就可以了 2 #include<stdio.h> 3 #include<string.h> 4 #include<string> 5 #include<algorithm> 6 #include<map> 7 using namespace std; 8 #define maxn 1005 9 int indegree[maxn];10 map<string,int>re;11 void init()12 {13 re.clear();14 memset(indegree,0,s 阅读全文
posted @ 2012-08-10 20:52
M_cag
阅读(166)
评论(0)
推荐(0)
摘要:
/*一道坑爹的水题,表示,你只要判断边数和点数之间的关系是不是edge+1=node,再用并查集判断环就ac了*/#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define maxn 100005int fa[maxn];bool vis[maxn];void init(){ int i; for(i=0;i<maxn;i++) fa[i]=i;}int findfather(int x){ if(x!=fa[x]) fa[x]=findfath.. 阅读全文
posted @ 2012-08-10 16:35
M_cag
阅读(217)
评论(0)
推荐(0)
摘要:
1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 #define maxn 1000001 5 __int64 a[maxn]; 6 void init() 7 { 8 __int64 i,temp; 9 __int64 count;10 for(i=1;i<maxn;i++)11 {12 count=1;13 temp=i;14 while(temp!=1)15 {16 if(temp%2... 阅读全文
posted @ 2012-08-10 14:56
M_cag
阅读(185)
评论(0)
推荐(0)
摘要:
先附上测试数据8 125 8 296 1 128 3 111 2 43 1 224 3 177 4 25 6 5 98 7 71 6 93 2 196 7 48个点12条边#include<stdio.h>#include<string.h>#include<queue>#include<algorithm>using namespace std;#define xx 10005int t,pre[xx];//边标号,表头;struct node{ int st,nd,ln,next;//起点,终点,长度,下一条边;}edge[xx];void 阅读全文
posted @ 2012-08-10 10:50
M_cag
阅读(1879)
评论(0)
推荐(0)
浙公网安备 33010602011771号