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) 编辑

导航