摘要: 写的时候思路很清晰,以面对的方向和它的右边为标准,这样写24个方向出来,不过代码量太大了,后来看了别人的思路后,原来可以写的这么简短!不过还是纪念下自己这个又臭又长的代码吧..View Code #include <stdio.h>#define x1 0#define y1 1#define z1 2#define x2 3#define y2 4#define z2 5int x,y,z,a,b,m;char str[10];void h(){ if(a>=3)m=-m; if(a==0||a==3)x+=m; if(a==1||a==4)y+=m; if(a==2... 阅读全文
posted @ 2011-12-15 23:20 104_gogo 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 枚举的思路,只是利用了行压缩来优化View Code #include <stdio.h>#include <string.h>int map[1005][1005],ar[1005];int main(){ int T,m,n,x,y,i,j,k,sum,ans; scanf("%d",&T); while (T--) { scanf("%d%d%d%d",&m,&n,&x,&y); for (i=0;i<m;i++) { for (j=0;j<n;j++) { ... 阅读全文
posted @ 2011-12-15 21:17 104_gogo 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 简单的最长公共子序列的变形,只是题有点吓人..View Code #include <stdio.h>#include <string.h>int dp[2005][2005],ar[2005];int max(int x,int y){ return x>y?x:y;}int main(){ int n,a,len1,len2,i,j; char str[2005],ans1[2005],ans2[2005]; while(scanf("%d",&n)!=EOF) { scanf("%s",str); for (i 阅读全文
posted @ 2011-12-15 21:13 104_gogo 阅读(165) 评论(0) 推荐(0) 编辑