摘要: 题意:破解一套1-6位长度密码的系统,寻找这样一个序列:对于N位的密码10^N+N-1长度的连续的长为N的串能够枚举完所有的密码。解法:构图之后直接dfs会超内存,因此需要使用栈来实现。调了很久。代码如下:#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;int N, mod, head[100005];int idx, lim, edge, top;int st 阅读全文
posted @ 2013-03-27 22:29 沐阳 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 题意:给定许多根棍子,这些棍子两头有不同的颜色,问是否能够存在这样一中组合方式使得所有的棍子首尾相连。解法:这题使用map处理字符串超时了,所以自己写了一个插值取模的字符串hash。只要判定图是否连通和度为奇数是否大于2个即可,不可能出现奇数个度为奇数的点。代码如下:#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#include <map>#include <string># 阅读全文
posted @ 2013-03-27 09:19 沐阳 阅读(227) 评论(0) 推荐(0) 编辑