2013
12-23

# 欧拉回路

3 3
1 2
1 3
2 3
3 2
1 2
2 3
0

1
0

//ashione 2011-6-1 ,欧拉回路检测
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define SetMax 1001
int in[SetMax],out[SetMax],map[SetMax][SetMax];
bool mark[SetMax];
void init(int n){
memset(mark,false,(n+1)*sizeof(bool));
memset(map,0,sizeof(map));
memset(in,0,(n+1)*sizeof(int));
memset(out,0,(n+1)*sizeof(int));
}
void dfs(int k,int n){//DFS寻找最大连通分量
mark[k]=true;
for(int i=1;i<=n;i++)
if(map[k][i] && !mark[i]){
dfs(i,n);
break;
}
}
int main(){
int n,m,a,b,i,j;
while(cin>>n && n){
cin>>m;
init(n);
while(m--){
scanf("%d %d",&a,&b);
map[a][b]=map[b][a]=1;
out[a]++,in[b]++;//无向图入度与出度
in[a]++,out[b]++;
}
dfs(1,n);
for(i=1;i<=n;i++)
if(out[i]!=in[i] || !mark[i] || in[i]%2==1 )//当节点入度不等于出度或者连通分量大于1或者为奇数入度则不为欧拉回路
break;
puts((i==n+1)?"1":"0");
}
return 0;
}

1. for(int i=1; i<=m; i++){
for(int j=1; j<=n; j++){
dp = dp [j-1] + 1;
if(s1.charAt(i-1) == s3.charAt(i+j-1))
dp = dp[i-1] + 1;
if(s2.charAt(j-1) == s3.charAt(i+j-1))
dp = Math.max(dp [j - 1] + 1, dp );
}
}
这里的代码似乎有点问题？ dp(i)(j) = dp(i)(j-1) + 1;这个例子System.out.println(ils.isInterleave("aa","dbbca", "aadbbcb"));返回的应该是false

2. I go through some of your put up and I uncovered a good deal of expertise from it. Many thanks for posting this sort of exciting posts