上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 99 下一页

2012年7月21日

poj 2002 Babelfish

摘要: 算法:1.map 985ms..2.Trie树,250ms..4倍。。3.排序+二分查找 200ms左右struct dict{ char a[11]; char b[11];}dic[100001];4. HASH将字符串映射为一个HASH值,HASH函数可以从网上自己找一个用静态链表处理冲突,速度最快235msView Code /*代码自己没写了,此代码来自http://wingszero.blogbus.com/logs/60733344.html*/#include<iostream>#include<string>using namespace std;co 阅读全文

posted @ 2012-07-21 16:28 more think, more gains 阅读(146) 评论(0) 推荐(0) 编辑

poj 2022 Squares

摘要: 算法:1.枚举任意两个点,根据公式计算出另外两个点坐标是否存在。2.查找算法,可以用HASH或二分查找。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>using namespace std;struct Point{ int x,y; bool operator < ( const Point &A) const { if( x != A.x ) return x &l 阅读全文

posted @ 2012-07-21 14:35 more think, more gains 阅读(204) 评论(0) 推荐(0) 编辑

poj 1840

摘要: 算法:1.分成两半部分,前面两个一组,后面三个一组。2. HASH保存前两个数和,或二分查找。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#define MAXN 12500000short int hash[26500000];int a, b, c, d, e;int main( ) { while( scanf("%d%d%d%d%d", &a, &b, &c, &d, &e) != EOF) { int cnt 阅读全文

posted @ 2012-07-21 07:31 more think, more gains 阅读(149) 评论(0) 推荐(0) 编辑

2012年7月20日

Saving Princess claire 最短路

摘要: 比赛中非常水的一道题,结束时大家才做。。没提交上。。泪奔。。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<iostream>#include<algorithm>#include<map>#include<math.h>#include<queue>using namespace std;int N,M,C,n, maxn;int xx[]={1,0,0,-1};int yy[]={0,1,-1,0}; 阅读全文

posted @ 2012-07-20 22:25 more think, more gains 阅读(160) 评论(0) 推荐(0) 编辑

HDU 4300 Clairewd’s message

摘要: 这题比赛时,题意看了N久才看懂,囧。。。算法又错了两次:错误算法:1. 用二分找密文长度。。2.用只求了一次next函数找最长前缀匹配后缀,忽略了其可能有交集,在这题中是不允许的。。正确算法:饶了这么多弯,终于回到正道了,求一次KMP就可以解决。用截获的文本后半段做主串,用前半段做模式串。用KMP求出其最长匹配主串的长度。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>char str[101000];char st[101000];char temp1[101000];char 阅读全文

posted @ 2012-07-20 22:22 more think, more gains 阅读(179) 评论(0) 推荐(0) 编辑

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 99 下一页

导航