amazing

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6. #define R(a,b,c) for(register int a = (b); a <= (c); ++ a)
  7. #define nR(a,b,c) for(register int a = (b); a >= (c); -- a)
  8. #define Max(a,b) ((a) > (b) ? (a) : (b))
  9. #define Min(a,b) ((a) < (b) ? (a) : (b))
  10. #define Fill(a,b) memset(a, b, sizeof(a))
  11. #define Swap(a,b) a^=b^=a^=b
  12. #define ll long long
  13. #define ON_DEBUG
  14. #ifdef ON_DEBUG
  15. #define D_e_Line printf("\n\n----------\n\n")
  16. #define D_e(x) cout << #x << " = " << x << endl
  17. #define Pause() system("pause")
  18. #else
  19. #define D_e_Line ;
  20. #endif
  21. struct ios{
  22. template<typename ATP>ios& operator >> (ATP &x){
  23. x = 0; int f = 1; char c;
  24. for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
  25. while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
  26. x*= f;
  27. return *this;
  28. }
  29. }io;
  30. using namespace std;
  31. const int N = 270007;
  32. int f[61][N];
  33. int main(){
  34. int n;
  35. io >> n;
  36. int ans = 0;
  37. R(i,1,n){
  38. int x;
  39. io >> x;
  40. f[x][i] = i + 1;
  41. ans = Max(ans, x);
  42. }
  43. R(i,2,58)
  44. R(j,1,n){
  45. if(!f[i][j])
  46. f[i][j] = f[i-1][f[i-1][j]];
  47. if(f[i][j])
  48. ans = i;
  49. }
  50. printf("%d",ans);
  51. return 0;
  52. }

normal

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6. #define R(a,b,c) for(register int a = (b); a <= (c); ++ a)
  7. #define nR(a,b,c) for(register int a = (b); a >= (c); -- a)
  8. #define Max(a,b) ((a) > (b) ? (a) : (b))
  9. #define Min(a,b) ((a) < (b) ? (a) : (b))
  10. #define Fill(a,b) memset(a, b, sizeof(a))
  11. #define Swap(a,b) a^=b^=a^=b
  12. #define ll long long
  13. #define ON_DEBUG
  14. #ifdef ON_DEBUG
  15. #define D_e_Line printf("\n\n----------\n\n")
  16. #define D_e(x) cout << #x << " = " << x << endl
  17. #define Pause() system("pause")
  18. #else
  19. #define D_e_Line ;
  20. #endif
  21. struct ios{
  22. template<typename ATP>ios& operator >> (ATP &x){
  23. x = 0; int f = 1; char c;
  24. for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
  25. while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
  26. x*= f;
  27. return *this;
  28. }
  29. }io;
  30. using namespace std;
  31. const int N = 257;
  32. int f[N][N];
  33. int main(){
  34. int n;
  35. io >> n;
  36. int ans = 0;
  37. R(i,1,n){
  38. io >> f[i][i];
  39. ans = Max(ans, f[i][i]);
  40. }
  41. R(i,1,n){
  42. R(l,1,n-i+1){
  43. int r = l + i - 1;
  44. R(k,l,r-1){
  45. if(f[l][k] == f[k+1][r]){
  46. f[l][r] = Max(f[l][r], f[l][k] + 1);
  47. ans = Max(ans, f[l][r]);
  48. }
  49. }
  50. }
  51. }
  52. printf("%d", ans);
  53. return 0;
  54. }

BZOJ4580/Luogu3147 [Usaco2016 Open]248的更多相关文章

  1. 【bzoj4580】[Usaco2016 Open]248 区间dp

    题目描述 Bessie likes downloading games to play on her cell phone, even though she does find the small t ...

  2. bzoj4580: [Usaco2016 Open]248(区间dp)

    4580: [Usaco2016 Open]248 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 255  Solved: 204[Submit][S ...

  3. BZOJ4580: [Usaco2016 Open]248

    n<=248个数字,可以进行这样的操作:将相邻两个相同的数字合并成这个数字+1,求最大能合成多少. f(i,j)--区间i到j能合成的最大值,f(i,j)=max(f(i,k)+1),f(i,k ...

  4. 4580: [Usaco2016 Open]248

    Description Bessie likes downloading games to play on her cell phone, even though she does find the ...

  5. BZOJ 4580: [Usaco2016 Open]248

    Description 一个序列,每次可以把相邻的两个数合为一个,价值+1,求最后的最大价值. Sol 区间DP. \(f[i][j]\) 表示 \(i-j\) 中合成一个数字为多少,转移就是枚举断点 ...

  6. BZOJ 4576: [Usaco2016 Open]262144

    Description 一个序列,每次可以将两个相同的数合成一个数,价值+1,求最后最大价值 \(n \leqslant 262144\) Sol DP. 这道题是 BZOJ 4580: [Usaco ...

  7. bzoj Usaco补完计划(优先级 Gold>Silver>资格赛)

    听说KPM初二暑假就补完了啊%%% 先刷Gold再刷Silver(因为目测没那么多时间刷Silver,方便以后TJ2333(雾 按AC数降序刷 ---------------------------- ...

  8. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  9. 【BZOJ 4580】【Usaco2016 Open】248

    http://www.lydsy.com/JudgeOnline/problem.php?id=4580 区间dp,f(i,j)表示区间[i,j]全部合成一个数,这个数是多少. 可以归纳证明[i,j] ...

随机推荐

  1. CMU 15-445 数据库课程第四课文字版 - 存储2

    熟肉视频地址: CMU数据库管理系统课程[熟肉]4.数据库存储结构2(上) CMU数据库管理系统课程[熟肉]4.数据库存储结构2(下) 1. 面向日志的存储 上节课我们讲完了面向元组的存储,这节课从面 ...

  2. JS - 使用 html2canvas 将页面转PDF

    JS - 使用 html2canvas 将页面转PDF 本方法可以将页面元素块转为pdf. 网站地址 jspdf.js 官网地址:http://jspdf.com GitHub 主页:https:// ...

  3. git 无法拉取最新代码

    删除本地文件后,想从远程仓库中重新新Pull最新代码,但是执行了git pull origin develop 命令后始终无法拉取下来 提示 Already up-to-date. 原因:当前本地库处 ...

  4. 意味着JNPF迈入新时代的3.4版本,与3.3.3版本有着哪些功能区别呢?

    在线开发‍ 3.3.3版本 同一个功能分功能设计和移动设计 功能设计没有更换模式 功能设计没有同步菜单 功能设计和移动设计无表模式 3.4.1版本 同一个功能可以在功能设计里面设计,根据客户需求自己选 ...

  5. 合宙AIR105(二): 时钟设置和延迟函数

    目录 合宙AIR105(一): Keil MDK开发环境, DAP-Link 烧录和调试 合宙AIR105(二): 时钟设置和延迟函数 Air105 的时钟 高频振荡源 芯片支持使用内部振荡源, 或使 ...

  6. 关于Vue 移动端适配 (px2rem 插件将px转为rem)

    一.安装 npm install px2rem-loader lib-flexible --save 二.入口文件main.js加上 import 'lib-flexible/flexible.js' ...

  7. KVM虚拟机安装及桥接网络配置

    1.查看CPU是否支持intel或AMD的虚拟技术 cat /proc/cpuinfo | grep -E "vmx|svm" --color --vmx intel的CPU sv ...

  8. centos服务器安全技巧

    系统管理员都应该烂熟于心的: 务必保证系统是 最新的 经常更换密码 - 使用数字.字母和非字母的符号组合 给予用户 最小 的权限,满足他们日常使用所需即可 只安装那些真正需要的软件包 1. 更改默认的 ...

  9. SpringBoot项目集成Swagger启动报错: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is

    使用的Swagger版本是2.9.2.knife4j版本是2.0.4. SpringBoot 版本是2.6.2将SpringBoot版本回退到2.5.6就可以正常启动

  10. 利用IDEA搭建SpringBoot项目,整合mybatis

    一.配置文件.启动项目 生成之后这几个文件可以删掉的 配置application spring.datasource.url=jdbc:mysql://localhost:3306/test?serv ...