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

2012年9月13日

POJ 1976
摘要: 题意:一维序列,用三个相等长度区间区覆盖,使得覆盖的权值最大题解:dp[i][j]为前i个数用j个区间覆盖的最大值,状态转移分为覆盖第i个数和不覆盖第i个数两种。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int dp[50005][4],sum[50005]; 6 int main() 7 { 8 int T; 9 for(scanf("%d",&T);T;T--)10 {11 in 阅读全文
posted @ 2012-09-13 20:17 tmeteorj 阅读(503) 评论(0) 推荐(0)
 
POJ 1815
摘要: 求字典序最小的最小割,首先,对于每一个不是源点和汇点,拆成两个点,有一条容量为一的边。求一次最小割后,针对每一个结点,按照字典序枚举若是删了它与它映射过去的另一个点之间的边是否会使得最小割变小,是则必须删它,否则,不用。本来应该dfs求出S,T集合的来降低复杂度的(判断删去一条边是否会使得最小割变小),但是这道题点数边数都很小,直接暴力就行了。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=5 阅读全文
posted @ 2012-09-13 19:46 tmeteorj 阅读(302) 评论(0) 推荐(0)
 
 

2012年9月10日

POJ 2668
摘要: 将原来所有的的i按照d/i上取整=k的划分为各个区间[next,now),这区间里的ans值就等于(now-next)*k初始now=n+1,k=1,然后每次next就等于d/i,k依次递增,实际上,不是每一个k的next和now所指代的区间都有意义,即next<now,所以,每当遇到一个这种没有意义的next和now时,就通过d/(now-1)上取整找到新的k,这样就可以大大节省时间。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<alg 阅读全文
posted @ 2012-09-10 21:06 tmeteorj 阅读(143) 评论(0) 推荐(0)
 
 

2012年9月8日

POJ 2442
摘要: 直接用优先队列bfs+set判重水过,需要注意的是,因为m<=100,所以用short就可以不超内存了= =!View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<queue> 5 #include<set> 6 using namespace std; 7 int ar[105][2005],n,m; 8 struct data 9 {10 short p[105];11 int sum;12 bool operato 阅读全文
posted @ 2012-09-08 19:27 tmeteorj 阅读(326) 评论(0) 推荐(0)
 
HDOJ 4276
摘要: 先将1到n的路径上的点进行缩点,总时间减去该路径长度,然后这道题就和ZOJ 3626一模一样了,也就是,树形DP。。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int head[200],nc,dp[200][600],v[200]; 6 struct edge 7 { 8 int to,cost,next; 9 }edge[1000]; 10 struct data 11 { 12 int a,b,c; 13 阅读全文
posted @ 2012-09-08 18:20 tmeteorj 阅读(205) 评论(0) 推荐(0)
 
HDOJ 4267
摘要: 让人一看就知道是线段树的题,不过具体操作起来就比较DT了。我的做法是每个结点保存以这个区间开头的每隔多少个数加上一个数,说白了,就是题目说的第一种操作的k,c,k<=10,所以一个s[11]数组可以解决。然后每个1 a b k c 操作,就是对区间[a,b]的s[k]加上一个c,若是线段树中存在[a,b]直接加上即可,否则,左孩子仍然照加,右孩子就需要找第一个属于[a,b]区间且i-a%k==0的数,变成给[i,b]的s[k]加上c计算某个点的值时,需要把涵盖这个点的所有线段上的s数组对它的影响算进去,即看pos-left mod i是否等于0。View Code 1 #include& 阅读全文
posted @ 2012-09-08 17:54 tmeteorj 阅读(214) 评论(0) 推荐(0)
 
POJ 2688
摘要: 找一条哈密顿路,爆搜完事#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;int path[20][20];bool mark[30][30];int map[30][30];char ss[30][30];struct data{ int x,y,step; data(){}; data(int _x,int _y,int _step){x=_x;y=_y;step=_step;}};data po[15];int dr[ 阅读全文
posted @ 2012-09-08 11:27 tmeteorj 阅读(197) 评论(0) 推荐(0)
 
 

2012年9月6日

POJ 2573
摘要: 还有一道比这道题更简单但是一样的题,忘了题号了,那题只求最少时间,实际上两题差不多,贪心策略1、让划船划的最快的人依次与最慢的两人组队去对面,然后他在把船划回来,这样到对岸的时间花费很多,但是回来的时间少。2、先让最快的两人去对岸,然后让其中一人把船划回来,再让最慢的两人组队去对岸,让先前还剩下那人把船划回来,这样使得到对岸的时间减少了,但是划回来的时间增多了。依靠上面两个贪心策略,执行一次后得到的状态都是相等的,于是可以递归解决,每次进行比较,看哪种贪心策略更优,直到要过河的人小于4#include<cstdio>#include<cstring>#include&l 阅读全文
posted @ 2012-09-06 21:06 tmeteorj 阅读(377) 评论(0) 推荐(0)
 
POJ 2565
摘要: 模拟,照着说的做就行了。#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const double eps=1e-8;struct data{ int h,m,s; double tot,speed; data(int _h,int _m,int _s) { h=_h;m=_m;s=_s; tot=_h*60+_m+_s/60.0; speed=0; } data(){} void print() { ... 阅读全文
posted @ 2012-09-06 20:32 tmeteorj 阅读(194) 评论(0) 推荐(0)
 
POJ 1690
摘要: 好坑爹的一道字符串类型的模拟题,看来我就不适合做这种题,无论怎样简单,总会错几次才能对。#include<cstdio>#include<cstring>using namespace std;int main(){ int T; for(scanf("%d ",&T); T; T--) { char s[1000]; char ans[1000]; int st[1000]; gets(s); int len,i,j,num=0; for(i=j=0; s[i]; i++) {... 阅读全文
posted @ 2012-09-06 19:45 tmeteorj 阅读(234) 评论(0) 推荐(0)
 
 
上一页 1 ··· 14 15 16 17 18 19 20 21 下一页

公告


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