• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
tmeteorj
Nothing is so big that it is impossible to get over, and hurt only serves to make us stronger. 没有什么事是大到无法战胜的,痛苦也只会让我们变得更加坚强。
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

2012年10月20日

POJ 1816
摘要: 题意:给出n个模式串,串中除开小写字母外,?代表一个字符,*代表可空的任意字符串,然后再给出m个字符串,问有多少个模式串可以与之匹配。题解:通过模式串建立字典树,接着就是用字符串去dfs就行了,需要注意的就是遇到当前节点为*则还可以继续走当前结点,由于每次dfs要么字典树匹配深度加1,要么字符串位置加1,所以不会出现死循环。另外这题有些卡内存,模式串可能一样,记录每个结点代表哪些模式串时可以参照图论建边的方法,建一个邻接表储存各个结点的模式串信息。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include< 阅读全文
posted @ 2012-10-20 15:09 tmeteorj 阅读(641) 评论(0) 推荐(0)
 
POJ 3612
摘要: 题意:n个序列,权值为相邻差值的绝对值之和*c。可以给每个数添加一个x,代价为x*x。求最小权。题解:dp[i][j]为第i个数为j时的最小代价,转移时分两种情况,如果i-1的高度小于j,那么dp[i][j]=dp[i-1][k]+(a[i]-j)^2+(j-k)*c=(a[i]-j)^2+j*c+(dp[i-1][k]-k*c),记录所有小于j的dp[i-1][k]-k*c最小值为low[j],转移复杂度就变成1了,如果i-1高度不低于j,也同上,只是将-k*c改成了+k*c,j*c变成-j*cView Code 1 #include<cstdio> 2 #include< 阅读全文
posted @ 2012-10-20 14:09 tmeteorj 阅读(305) 评论(0) 推荐(0)
 
POJ 1962
摘要: 题意:给定n台电脑,初始都是以自己作为中心。然后一些询问,E x,问x距离中心多远。 I x y 建立一条x到y的长度为|x-y|(mod 1000)的边,且使得原来x机群的中心转移到y机群上。题解:并查集,再额外记录每个点到中心的距离。View Code 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 const int N=30000; 6 int fa[N],dist[N]; 7 int Find(int x) 8 { 9 if( 阅读全文
posted @ 2012-10-20 11:24 tmeteorj 阅读(391) 评论(0) 推荐(0)
 
POJ 2408
摘要: 题意:对字符串分类,按照每类大小由大到小输出前五个类,没类中相同的字符串只输出一次。题解:各种STLView Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<queue> 5 #include<string> 6 #include<map> 7 #include<set> 8 using namespace std; 9 struct data10 {11 vector<string> vec; 阅读全文
posted @ 2012-10-20 11:08 tmeteorj 阅读(348) 评论(0) 推荐(0)
 
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3