• 博客园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月18日

POJ 2441
摘要: 题意:n头牛,m个牧场,每头牛都有自己喜欢的牧场,然后问一牛一牧场的分配方案总数。题解:状态压缩dp,dp[i][state]为前i头牛,用了state的牧场时的总数。但是直接开n*2^m会爆空间,但是每头牛都只与前面一头牛相关,所以可以辗转一下,只记录两维即可。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int dp[2][(1<<20)+2]; 6 int main() 7 { 8 int n,m 阅读全文
posted @ 2012-10-18 21:50 tmeteorj 阅读(310) 评论(0) 推荐(0)
 
POJ 2424
摘要: 题意:给出饭店来人的顺序与人数,按照三种类型去坐,如果等待时间超过半个小时,客人就会走,问最后能接待多少客人。题解:大模拟!View Code 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 struct data 7 { 8 int t; 9 bool operator<(const data &ne)const 10 { 11 return t>ne.t; 12 } 阅读全文
posted @ 2012-10-18 21:24 tmeteorj 阅读(299) 评论(0) 推荐(0)
 
POJ 3497
摘要: 题意:给出预算b以及电脑零件n,每种类型均要买一个,求在预算范围内,所有零件配置最低的最大值。题解:二分答案View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<map> 5 #include<string> 6 #include<vector> 7 using namespace std; 8 map<string,int> MP; 9 const int inf=0x3f3f3f3f;10 stru 阅读全文
posted @ 2012-10-18 17:26 tmeteorj 阅读(356) 评论(0) 推荐(0)
 
POJ 1589
摘要: 题意:给出n个字符串,排成阵列,要求每行长度不超过60,且每列宽度为n个字符串中最长的那个的长度加2,最后一列就是最长的长度,要使行数尽可能少。题解:直接推导出最后需要多少行多少列,细心一点就没问题了。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char file[102][102][65]; 6 struct data 7 { 8 char s[70]; 9 bool operator<(const da 阅读全文
posted @ 2012-10-18 13:46 tmeteorj 阅读(189) 评论(0) 推荐(0)
 
POJ 2261
摘要: 题意:16个国家的竞赛图,给出每个国家打败其他国家的概率,求每个国家最后夺冠的概率。题解:dp[i][k]代表第i个国家成功进入第k轮的概率,那么dp[i][k]=sum(dp[i][k-1]*dp[j][k-1]*vs[i][j]),其中,j为这一轮i可能面对的国家。PS:国家名字占10个字符,还需要空一格再输出概率~View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char name[20][50]; 6 doub 阅读全文
posted @ 2012-10-18 13:24 tmeteorj 阅读(290) 评论(0) 推荐(0)
 
POJ 3693
摘要: 题意:给定一个字符串,求其中一个由循环子串构成且循环次数最多的一个子串,有多个就输出最小字典序的。题解:后缀数组+RMQ。 1、枚举循环串的长度ll,然后如果它出现了两次,那么它一定会覆盖s[0],s[ll],s[ll*2].....这些点中相邻的两个。 2、再枚举它覆盖的最左边的那个s[ll*i],通过rmq求s[ll*i]与s[ll*i+ll]的最长公共前缀K,可以看出,从[ll*i,ll*i+ll+K]这个区间内,s[ll*i,ll*(i+1)-1]重复出现了K/ll+1次。 3、在第2步中,还有可能就是循环串并不是从ll*i开始的,所以要枚举它前面[ll*(i-1)+1,l... 阅读全文
posted @ 2012-10-18 12:58 tmeteorj 阅读(1719) 评论(0) 推荐(0)
 
 

公告


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