随笔分类 -  hash

poj-1733 Parity game ****
摘要:1 /* 2 * poj-1733 Parity game.cpp 3 * 4 * Created on: 2012-2-17 5 * Author: LongDou 6 * 7 * 8 * hash离散化 + 并查集 9 * 10 * 设s[0]=0,s[i]=a[1]+a[2]+...+a[i],则信息i j even等价于a[i]+...+a[j]为偶数,即 11 s[j]-s[i-1]为偶数,即s[j]与s[i-1]同奇偶。这样,每条信息都可以变为 12 s[i-1]和s[j]是否同... 阅读全文

posted @ 2012-02-17 17:12 龙豆 阅读(586) 评论(1) 推荐(1) 编辑

poj-2170 Lattice Animals *****
摘要:/* * 2170.cpp * * 很繁的一个题。。。 * * dfs + hash * 这个速度很慢, 不过答案应该都是对的, 先贴上来吧。。 最近没时间做了 。 以后再改。。 * * 可以改进的有 搜索方式 和 hash函数 * * Created on: 2011-10-17 */#include <cstdio>#include <cstring>using namespace std;const int maxp = 5000 + 10;const int maxn = 25, z = 12;const int hashNum = 19997;const in 阅读全文

posted @ 2011-10-18 22:49 龙豆 阅读(682) 评论(0) 推荐(0) 编辑

poj-3349 Snowflake Snow Snowflakes *
摘要:/* * hash。。 链表法 * 3349.cpp * * 需注意如何判断两个雪花一样 * 看数据: * 1 1 2 0 0 0 * 1 1 0 0 0 2 * * Created on: 2011-7-21 * Author: */#include <cstdio>using namespace std;const int MAXN = 100000 + 5;int n;bool vis[MAXN] = {};struct SData{ int a[6]; SData *pre, *next;};SData *table[MAXN];SData snow[MAXN];//相加 阅读全文

posted @ 2011-07-21 18:14 龙豆 阅读(320) 评论(0) 推荐(0) 编辑

导航

点击右上角即可分享
微信分享提示