2012年9月24日
摘要: 练习DFS。CODE:#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#defineMAXN102usingnamespacestd;constintM=1001;constintINF=0X3F3F3F3F;intG[M][M];boolcolor[M],save[M];intMAX;intn,m;intcheck(intu){for(intv=1;v<=n;v++){if(G[u][v]&&color[v])return0;}re 阅读全文
posted @ 2012-09-24 21:15 有间博客 阅读(184) 评论(0) 推荐(0) 编辑
摘要: Coloring程度★ 難度★Coloring替一張圖的各個元件都塗上顏色,並規定相鄰元件不可同色。一張圖的上色情形,稱做一種「著色」。根據元件的不同,著色可分為許多種類型,例如點著色( vertex coloring )、邊著色( edge coloring )、面著色( face coloring )。【註:英文「 Coloring 」為名詞,中文「著色」為動詞,英翻中致使文法不通,請多見諒。】Vertex Coloring程度★ 難度★Vertex Coloring「點著色」。替一張圖上的每個點塗上顏色,並且規定以邊相連的相鄰兩點不可同色。 UVa19310004Vertex Chrom 阅读全文
posted @ 2012-09-24 19:55 有间博客 阅读(618) 评论(0) 推荐(0) 编辑
摘要: 手写的next_permutation比库函数写的高了一倍的时间额。CODE:#include<iostream>#include<algorithm>#include<cstdlib>#include<cstdio>#include<cstring>usingnamespacestd;intmain(){intT;scanf("%d",&T);while(T--){intN,H;chars[20]={'\0'};scanf("%d%d",&N,&H);f 阅读全文
posted @ 2012-09-24 17:58 有间博客 阅读(161) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<algorithm>#include<cstdlib>#include<cstdio>#include<cstring>usingnamespacestd;chars[11];intmain(){inttimes=0;intT;scanf("%d",&T);while(T--){scanf("%s",s);intn=strlen(s);sort(s,s+n);do{printf("%s\n",s);}while(n 阅读全文
posted @ 2012-09-24 17:25 有间博客 阅读(125) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<algorithm>#include<cstdlib>#include<cstdio>#include<cstring>usingnamespacestd;chars[210];intmain(){while(~scanf("%s",s)){intn=strlen(s);sort(s,s+n);do{printf("%s\n",s);}while(next_permutation(s,s+n));}return0;} 阅读全文
posted @ 2012-09-24 17:18 有间博客 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 无耻地使用了STL,BS自己。关于next_permutation的用法:http://www.slyar.com/blog/stl_next_permutation.htmlCODE:#include<iostream>#include<algorithm>#include<cstdlib>#include<cstdio>#include<cstring>usingnamespacestd;inta[1001];chars[1001];intmain(){while(scanf("%s",s)&& 阅读全文
posted @ 2012-09-24 17:03 有间博客 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Sample Input2-20 20-30 20-10 -5010 -50Sample Output0 1 (-100 21)错误的测试数据,害人。CODE:#include<iostream>#include<cstdio>#include<cstring>usingnamespacestd;structnode{intx,y;}a[1001];intcnt;voidget(intn){inti,j,k;intcnt1,cnt2;for(i=-100;i<=100;i++){for(j=-100;j<=100;j++){cnt1=cnt2=0 阅读全文
posted @ 2012-09-24 12:48 有间博客 阅读(154) 评论(0) 推荐(0) 编辑