andre_joy

导航

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页

2012年7月13日

hdu 1856

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1856题意:找一组的最大人数。mark:并查集,注意最后搜索的细节。虽然wa了很多次,但是ac了还是很爽的。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int a[200010], b[200010], c[200010][2], d[100010];int j;int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b 阅读全文

posted @ 2012-07-13 17:39 andre_joy 阅读(122) 评论(0) 推荐(0) 编辑

hdu 1232

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1232题意:中文……mark:并查集。代码:#include <stdio.h>int s[1010];int find(int a){ if(s[a] == a) return a; return s[a] = find(s[a]);}void merge(int a, int b){ int p = find(a), q = find(b); if(p != q) s[p] = q;}int main(){ int n,m,a,b; int i,sum; w... 阅读全文

posted @ 2012-07-13 13:58 andre_joy 阅读(163) 评论(0) 推荐(0) 编辑

hdu 1253

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1253题意:中文……mark:bfs,wa了无数次啊,,细节处理的不好,没注意走不出去的情况。可能有两种,第一种根本无法走到门,第二种门本来就是死路。代码:#include <stdio.h>#include <string.h>int s[130000][3],d[50][50][50],h[50][50][50],a,b,c,t;void bfs(){ int front = 0, rear = 1; int aa,bb,cc,aaa,bbb,ccc,i; int tab[6 阅读全文

posted @ 2012-07-13 11:48 andre_joy 阅读(189) 评论(0) 推荐(0) 编辑

2012年7月12日

hdu 1372

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1372题意:按照国际象棋规则马最少几步从开始点走到终点。mark:bfs,仔细。代码:#include <stdio.h>#include <string.h>int a[100][2],d[8][8];char p[5],q[5];void bfs(){ int front = 0,rear = 1,m,n; d[p[0]-'a'][p[1]-'0'-1] = 0; a[0][0] = p[0]-'a'; a[0][1] = p[ 阅读全文

posted @ 2012-07-12 22:40 andre_joy 阅读(274) 评论(0) 推荐(0) 编辑

hdu 2717

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2717题意:三种走法+1,-1,*2,最少几步到指定点。mark:wa了好多次。bfs算法,注意临界条件。代码:#include <stdio.h>#include <string.h>int a[100010],d[100010],n,k;void bfs(){ int front = 0,rear = 1,nn; a[0] = n; d[n] = 0; while(front != rear) { nn = a[front++]; if(nn... 阅读全文

posted @ 2012-07-12 22:08 andre_joy 阅读(188) 评论(0) 推荐(0) 编辑

POJ 1579

摘要: 地址:http://poj.org/problem?id=1579题意:按照题目要求递归。mark:直接递归肯定是TLE的。记忆化深度搜索。代码:#include <stdio.h>int s[21][21][21];int w(int a, int b, int c){ if(a <= 0 || b <= 0 || c <= 0) return 1; if(a > 20 || b > 20 || c > 20) return s[20][20][20] = w(20, 20, 20); if(s[a][b][c]) return s[a][b] 阅读全文

posted @ 2012-07-12 18:50 andre_joy 阅读(165) 评论(0) 推荐(0) 编辑

hdu 1241

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1241题意:跟2952一样,只不过多加了四个方向。mark:多加了四个方向之后,遍历的时候不用打表了,可以直接枚举。代码:#include <stdio.h>char a[110][110];int m,n;void ss(int x, int y){ int i,j,xx,yy; a[x][y] = '1'; for(i = -1; i < 2; i++) for(j = -1; j < 2; j++) { xx = x+i; ... 阅读全文

posted @ 2012-07-12 18:25 andre_joy 阅读(222) 评论(0) 推荐(0) 编辑

hdu 2952

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2952题意:找分开的#最多的片数mark:dfs.同1312一样。代码:#include <stdio.h>char a[110][110];int h,w;void ss(int x, int y){ int tab[4][2] = {0,1,0,-1,-1,0,1,0}; int i,xx,yy; a[x][y] = '1'; for(i = 0; i < 4; i++) { xx = x+tab[i][0]; yy = y+tab[i][1... 阅读全文

posted @ 2012-07-12 18:04 andre_joy 阅读(147) 评论(0) 推荐(0) 编辑

hdu 1312

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1312题意:找可以到达的黑格子。mark:dfs..代码:#include <stdio.h>char a[25][25];int sum;void ss(int w, int h, int x, int y){ if(y > 0 && a[x][y-1] == '.') { a[x][y-1] = '1'; sum++; ss(w, h, x, y-1); } if(x < h-1 && a[x+1][y] == 阅读全文

posted @ 2012-07-12 17:48 andre_joy 阅读(133) 评论(0) 推荐(0) 编辑

UVa 10071

摘要: 地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1012题意:给定t时刻速度v,求2t时刻位移。mark:化简位移公式。代码:#include <stdio.h>int main(){ int a,b; while(~scanf("%d%d", &a, &b)) printf("%d\n", 2*a*b); return 0;} 阅读全文

posted @ 2012-07-12 16:31 andre_joy 阅读(92) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页