摘要: 类似于骨牌问题。我的做法就是首先看能不能横着排满,然后看能不能竖着排满,都不行的话就考虑一些横着排,一些竖着排,看能不能满足要求,最后也就转化为求ax+by=n有没有非负解的问题。可是我用扩展欧几里得打了,超时,无奈只能纯枚举了,枚举放1个、2个、3个...直到放不下为止。这说明测试数据很操蛋。/* * hdu2965/win.cpp * Created on: 2012-11-4 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath& 阅读全文
posted @ 2012-11-06 21:42 moonbay 阅读(231) 评论(0) 推荐(0)
摘要: 这题本来以为得DFA的,仔细审题以后发现,题目说每个关键字前4个字母不同(这意味着每个关键字结束的节点都是不同的),而且长度不超过60,马上醒悟,只要用所有的关键字建一棵Trie树,然后把主串跑一遍就可以了,复杂度为主串长度*60,肯定能过啊。。。/* * hdu1277/win.cpp * Created on: 2012-11-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime> 阅读全文
posted @ 2012-11-06 19:43 moonbay 阅读(171) 评论(0) 推荐(0)