细数一下这两天做过的值得总结的一些题Orz......

  HDU 2571 简单dp,但是一开始WA了一发。原因很简单:没有考虑仔细。

  如果指向该点的所有点权值都为负数,那就错了(我一开始默认初始值为0)

  这是非常基础的典型DAG模型,好久不做,手明显生了……

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define REP(i,n) for(int i(0); i < (n); ++i)
  6. #define rep(i,a,b) for(int i(a); i <= (b); ++i)
  7. #define dec(i,a,b) for(int i(a); i >= (b); --i)
  8. #define for_edge(i,x) for(int i = H[x]; i; i = X[i])
  9.  
  10. #define LL long long
  11. #define ULL unsigned long long
  12. #define MP make_pair
  13. #define PB push_back
  14. #define FI first
  15. #define SE second
  16. #define INF 1 << 30
  17.  
  18. const int N = + ;
  19. const int M = + ;
  20. const int Q = + ;
  21. const int A = + ;
  22.  
  23. int f[A][Q], c[A][Q];
  24. int T;
  25. int n, m;
  26.  
  27. int main(){
  28. #ifndef ONLINE_JUDGE
  29. freopen("test.txt", "r", stdin);
  30. freopen("test.out", "w", stdout);
  31. #endif
  32.  
  33. scanf("%d ", &T);
  34. REP(Case, T){
  35. scanf("%d %d ", &n, &m);
  36. memset(f, , sizeof f);
  37. rep(i, , n) rep(j, , m) scanf("%d ", &c[i][j]);
  38. f[][] = c[][];
  39. rep(i, , m){
  40. int now = f[][i - ];
  41. rep(j, , i >> ) if (i % j == ) now = max(now, f[][j]);
  42. f[][i] = c[][i] + now;
  43. }
  44.  
  45. rep(i, , n) f[i][] = c[i][] + f[i - ][];
  46. rep(i, , n) rep(j, , m){
  47. int now = f[i][j - ];
  48. rep(k, , j >> ) if (j % k == ) now = max(now, f[i][k]);
  49. now = max(now, f[i - ][j]);
  50. f[i][j] = c[i][j] + now;
  51. }
  52. //rep(i, 1, n){ rep(j, 1, m) printf("%d ", f[i][j]); putchar(10);}
  53. printf("%d\n", f[n][m]);
  54. }
  55.  
  56. return ;
  57.  
  58. }

  还有就是记忆化搜索,很裸的一道题。 HDU1579

  题目也说了大数据时直接递归会超时,所以除了记忆化搜索,别无选择。

  

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define REP(i,n) for(int i(0); i < (n); ++i)
  6. #define rep(i,a,b) for(int i(a); i <= (b); ++i)
  7. #define dec(i,a,b) for(int i(a); i >= (b); --i)
  8. #define for_edge(i,x) for(int i = H[x]; i; i = X[i])
  9.  
  10. #define LL long long
  11. #define ULL unsigned long long
  12. #define MP make_pair
  13. #define PB push_back
  14. #define FI first
  15. #define SE second
  16. #define INF 1 << 30
  17.  
  18. const int N = + ;
  19. const int M = + ;
  20. const int Q = + ;
  21. const int A = + ;
  22.  
  23. int f[A][A][A];
  24. int x, y, z;
  25.  
  26. int cal(int x, int y, int z){
  27. if (x <= || y <= || z <= ) return ;
  28. if (x > || y > || z > ) return f[][][] = cal(, , );
  29. if (f[x][y][z] != -) return f[x][y][z];
  30. if (x < y && y < z) return f[x][y][z] = cal(x, y, z - ) + cal(x, y - , z - ) - cal(x, y - , z);
  31. else return f[x][y][z] = cal(x - , y, z) + cal(x - , y - , z) + cal(x - , y, z - ) - cal(x - , y - , z - );
  32. }
  33.  
  34. int main(){
  35. #ifndef ONLINE_JUDGE
  36. freopen("test.txt", "r", stdin);
  37. freopen("test.out", "w", stdout);
  38. #endif
  39.  
  40. memset(f, -, sizeof f);
  41. while (~scanf("%d%d%d", &x, &y, &z)){
  42. if (x == - && y == - && z == -) break;
  43. printf("w(%d, %d, %d) = %d\n", x, y, z, cal(x, y, z));
  44. }
  45.  
  46. return ;
  47.  
  48. }

  还有一道并查集裸题……HDU1232

  直接YY一个就A了……

  

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define REP(i,n) for(int i(0); i < (n); ++i)
  6. #define rep(i,a,b) for(int i(a); i <= (b); ++i)
  7. #define dec(i,a,b) for(int i(a); i >= (b); --i)
  8. #define for_edge(i,x) for(int i = H[x]; i; i = X[i])
  9.  
  10. #define LL long long
  11. #define ULL unsigned long long
  12. #define MP make_pair
  13. #define PB push_back
  14. #define FI first
  15. #define SE second
  16. #define INF 1 << 30
  17.  
  18. const int N = + ;
  19. const int M = + ;
  20. const int Q = + ;
  21. const int A = + ;
  22.  
  23. int f[N];
  24. int n, m;
  25. int x, y;
  26.  
  27. int getfather(int x){ return f[x] ? f[x] = getfather(f[x]) : x;}
  28.  
  29. int main(){
  30. #ifndef ONLINE_JUDGE
  31. freopen("test.txt", "r", stdin);
  32. freopen("test.out", "w", stdout);
  33. #endif
  34.  
  35. while (~scanf("%d", &n), n){
  36. scanf("%d", &m);
  37. memset(f, , sizeof f);
  38. while (m--){
  39. scanf("%d%d", &x, &y);
  40. int fa = getfather(x), fb = getfather(y);
  41. if (fa != fb) f[fa] = fb;
  42. }
  43.  
  44. int ans = ;
  45. rep(i, , n - ) rep(j, i + , n){
  46. int fa = getfather(i), fb = getfather(j);
  47. if (fa != fb){
  48. f[fa] = fb;
  49. ++ans;
  50. }
  51. if (ans >= n) break;
  52. }
  53.  
  54. printf("%d\n", ans);
  55. }
  56.  
  57. return ;
  58.  
  59. }

  剩下的一些水题都不好意思拿出来……之后要加大难度了……

  The End.

HDU 2016.11.12 做题感想的更多相关文章

  1. AtCoder Grand Contest 11~17 做题小记

    原文链接https://www.cnblogs.com/zhouzhendong/p/AtCoder-Grand-Contest-from-11-to-20.html UPD(2018-11-16): ...

  2. P2599 [ZJOI2009]取石子游戏 做题感想

    题目链接 前言 发现自己三岁时的题目都不会做. 我发现我真的是菜得真实. 正文 神仙构造,分讨题. 不敢说有构造,但是分讨我只服这道题. 看上去像是一个类似 \(Nim\) 游戏的变种,经过不断猜测结 ...

  3. 2016/1/12 第一题 输出 i 出现次数 第二题 用for循环和if条件句去除字符串中空格 第三题不用endwith 实现尾端字符查询

    import java.util.Scanner; public class Number { private static Object i; /* *第一题 mingrikejijavabu中字符 ...

  4. P6622 信号传递 做题感想

    题目链接 前言 在这里分享两种的做法. 一种是我第一直觉的 模拟退火.(也就是骗分) 还有一种是看题解才搞懂的神仙折半搜索加上 dp . 模拟退火 众所周知,模拟退火 是我这种没脑子选手用来骗分的好算 ...

  5. NOIP2016考前做题(口胡)记录

    NOIP以前可能会持续更新 写在前面 NOIP好像马上就要到了,感觉在校内训练里面经常被虐有一种要滚粗的感觉(雾.不管是普及组还是提高组,我都参加了好几年了,结果一个省一都没有,今年如果还没有的话感觉 ...

  6. NOIp 11.11/12

    最后一场比较正式的NOIp模拟赛,写一发小总结.题目没什么好说的,大部分很简单,先贴一下代码. 1111 T1 //string //by Cydiater //2016.11.11 #include ...

  7. U3D笔记11:47 2016/11/30-15:15 2016/12/19

    11:47 2016/11/30Before you can load a level you have to add it to the list of levels used in the gam ...

  8. 2016年12月16日 星期五 --出埃及记 Exodus 21:11

    2016年12月16日 星期五 --出埃及记 Exodus 21:11 If he does not provide her with these three things, she is to go ...

  9. 2016年12月11日 星期日 --出埃及记 Exodus 21:6

    2016年12月11日 星期日 --出埃及记 Exodus 21:6 then his master must take him before the judges. He shall take hi ...

随机推荐

  1. 成员变量和属性区别(@property那点事儿)

    历史由来: 接触iOS的人都知道,@property声明的属性默认会生成一个_类型的成员变量,同时也会生成setter/getter方法. 但这只是在iOS5之后,苹果推出的一个新机制.看老代码时,经 ...

  2. 踩到Framework7 Photo Browser 的一个坑

    最近在做的项目用了Framework7前端框架,功能确实比较强大!但这两天遇到一个坑,希望我的这点收获能给遇到这个问题的朋友一点帮助. 在使用Photo Browser 的时候,图片下方想放一个“点赞 ...

  3. 【Count Complete Tree Nodes】cpp

    题目: Given a complete binary tree, count the number of nodes. Definition of a complete binary tree fr ...

  4. 【Soft-Margin Support Vector Machine】林轩田机器学习技术

    Hard-Margin的约束太强了:要求必须把所有点都分开.这样就可能带来overfiiting,把noise也当成正确的样本点了. Hard-Margin有些“学习洁癖”,如何克服这种学习洁癖呢? ...

  5. 最短路径(Floyd法)

    最短路径法: 算法的主要思想是:单独一条边的路径也不一定是最佳路径. 从任意一条单边路径开始.所有两点之间的距离是边的权的和,(如果两点之间没有边相连, 则为无穷大). 对于每一对顶点 u 和 v,看 ...

  6. 转:Redis设置认证密码 Redis使用认证密码登录 在Redis集群中使用认证密码

    Redis默认配置是不需要密码认证的,也就是说只要连接的Redis服务器的host和port正确,就可以连接使用.这在安全性上会有一定的问题,所以需要启用Redis的认证密码,增加Redis服务器的安 ...

  7. serial console

    适用于: agent_ipmitool_socat pxe_ipmitool_socat 修改driver方式:更换ironic node的driver类型 yum install -y socat ...

  8. 以太访solidity常用的函数有哪些

    以太坊:什么是ERC20标准? 不以规矩,不能成方圆 许多人应该都听过 代码即法律(Code Is Law),因为程序写完了,无论执行多少次都会得到同样的结果,除非有外界因素的干扰.在多人协作的过程中 ...

  9. Actiivity 生命周期

    Actiivity 生命周期,如下图所示: onCreate onStart (onRestarted) onResume onPaused(to onResume(User navigates to ...

  10. selenium webdriver——JavaScript警告窗处理

    在WebDriver中处理JavaScript所生成的alert.confirm以及prompt,具体方法是使用switch_to_alert()方法定位到alert.confirm以及 prompt ...