用一种颜色,两种颜色,三种颜色去对图染色,染色成功则输出颜色数,否则输出4View Code 1 #include<stdio.h> 2 #include<string.h> 3 bool g[26][26]; 4 int used[26]; 5 int n; 6 bool dfs(int id,int color) 7 { 8 int i,j; 9 bool flag;10 for(i=0;i<color;i++)11 {12 flag=true;13 used[id]=i;14 for(j=0;j<id;j+... Read More
posted @ 2011-11-01 23:33 Because Of You Views(369) Comments(0) Diggs(0) Edit
不怎么会做这类题目额。。伤,看别人的View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define maxn 1010 4 int dp[maxn][maxn]; 5 int sum[maxn][maxn]; 6 const int mod = 1000000007; 7 int main() 8 { 9 int i,j;10 char s[maxn];11 while(scanf("%s",s)!=EOF)12 {13 int n=strlen(s);14 memset... Read More
posted @ 2011-11-01 21:51 Because Of You Views(352) Comments(0) Diggs(0) Edit
使用了书上讲的迭代加深搜索,假设删除一个点,两个点,三个点。。。每次都先找最短路径再枚举最短路径上的点删除,dfs实现,A的很顺利,呵呵。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 int n,m,k; 4 int tot; 5 bool goal; 6 int fa[60]; 7 bool flag[60]; 8 int d[50][100]; 9 int head[60];10 int Q[10000];11 struct node12 {13 int t,next;14 }edge[10005];15 Read More
posted @ 2011-11-01 21:03 Because Of You Views(483) Comments(4) Diggs(0) Edit