HDU 5316 Magician(线段树)

保姆级教程:在RK3588开发板上驱动多路MIPI摄像头(从VICAP配置到ISP调优) 本文详细介绍了在RK3588开发板上驱动多路MIPI摄像头的完整流程,从VICAP配置到ISP调优的全方位解析。通过硬件架构分析、开发环境搭建、设备树配置、V4L2数据采集以及ISP图像调优等步骤,帮助开发者高效实现多路摄像头驱动,适用于工业检测和智能安防等领域。 阅读详情

Magician

Time Limit: 18000/9000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 150    Accepted Submission(s): 42


Problem Description
Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an innate talent, gaining it through study and practice, or receiving it from another being, often a god, spirit, or demon of some sort. Some wizards are depicted as having a special gift which sets them apart from the vast majority of characters in fantasy worlds who are unable to learn magic.

Magicians, sorcerers, wizards, magi, and practitioners of magic by other titles have appeared in myths, folktales, and literature throughout recorded history, with fantasy works drawing from this background.

In medieval chivalric romance, the wizard often appears as a wise old man and acts as a mentor, with Merlin from the King Arthur stories representing a prime example. Other magicians can appear as villains, hostile to the hero.



Mr. Zstu is a magician, he has many elves like dobby, each of which has a magic power (maybe negative). One day, Mr. Zstu want to test his ability of doing some magic. He made the elves stand in a straight line, from position 1 to position n, and he used two kinds of magic, Change magic and Query Magic, the first is to change an elf’s power, the second is get the maximum sum of beautiful subsequence of a given interval. A beautiful subsequence is a subsequence that all the adjacent pairs of elves in the sequence have a different parity of position. Can you do the same thing as Mr. Zstu ?

 

Input
The first line is an integer T represent the number of test cases.
Each of the test case begins with two integers n, m represent the number of elves and the number of time that Mr. Zstu used his magic.
(n,m <= 100000)
The next line has n integers represent elves’ magic power, magic power is between -1000000000 and 1000000000.
Followed m lines, each line has three integers like 
type a b describe a magic.
If type equals 0, you should output the maximum sum of beautiful subsequence of interval [a,b].(1 <= a <= b <= n)
If type equals 1, you should change the magic power of the elf at position a to b.(1 <= a <= n, 1 <= b <= 1e9)
 

Output
For each 0 type query, output the corresponding answer.
 

Sample Input
  
1 1 1 1 0 1 1
 

Sample Output
  
1
 

Source
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5326  5325  5324  5323  5322 


/*
题意:在一个区间取数,取完的数按标号大小排序,如果标号为奇偶交替则为满足条件的序列,求满足条件序列的数的和的最大值
思路:线段树 ,a[0][0]代表这个偶开头,偶结尾,0,1,代表偶开头奇结尾
                 1  0         奇      偶      1  0     奇    偶

转化方程  在pushup 函数中,具体看该函数注释

非常可惜的地方是 比赛没有做出来,因为我的 query函数返回的是 ___int64 一直超时, 后来看别人博客,发现别人返回结构体,


*/

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)
typedef long long ll;
#define bug printf("hi\n")
#define INF -1000000005
#define N 100005

inline ll Max(ll x,ll y)
{
    return x>y?x:y;
}

struct stud{
  int le,ri;
  ll a[2][2];
  stud operator =(stud b)
  {
      for(int i=0;i<2;i++)
        for(int j=0;j<2;j++)
           b.a[i][j]=a[i][j];
      return *this;
  }
}f[N*4];

ll a[N];
int n,m;

void pushup(int pos)
{
   f[pos].a[0][0]=Max(f[L(pos)].a[0][0],f[R(pos)].a[0][0]); //左端点,右端点取较大
   f[pos].a[0][0]=Max(f[pos].a[0][0],f[L(pos)].a[0][0]+f[R(pos)].a[1][0]);//应该挺好理解
   f[pos].a[0][0]=Max(f[pos].a[0][0],f[L(pos)].a[0][1]+f[R(pos)].a[0][0]);

   f[pos].a[0][1]=Max(f[L(pos)].a[0][1],f[R(pos)].a[0][1]);
   f[pos].a[0][1]=Max(f[pos].a[0][1],f[L(pos)].a[0][0]+f[R(pos)].a[1][1]);
   f[pos].a[0][1]=Max(f[pos].a[0][1],f[L(pos)].a[0][1]+f[R(pos)].a[0][1]);

   f[pos].a[1][0]=Max(f[L(pos)].a[1][0],f[R(pos)].a[1][0]);
   f[pos].a[1][0]=Max(f[pos].a[1][0],f[L(pos)].a[1][0]+f[R(pos)].a[1][0]);
   f[pos].a[1][0]=Max(f[pos].a[1][0],f[L(pos)].a[1][1]+f[R(pos)].a[0][0]);

   f[pos].a[1][1]=Max(f[L(pos)].a[1][1],f[R(pos)].a[1][1]);
   f[pos].a[1][1]=Max(f[pos].a[1][1],f[L(pos)].a[1][0]+f[R(pos)].a[1][1]);
   f[pos].a[1][1]=Max(f[pos].a[1][1],f[L(pos)].a[1][1]+f[R(pos)].a[0][1]);
}

void update(int pos,int le,int ri)
{
    if(f[pos].le==le&&f[pos].ri==le)
    {
        if(le&1)
        {
            f[pos].a[1][1]=ri;
            f[pos].a[0][0]=INF;
            f[pos].a[0][1]=f[pos].a[1][0]=INF;
        }
        else
        {
            f[pos].a[0][0]=ri;
            f[pos].a[0][1]=f[pos].a[1][0]=f[pos].a[1][1]=INF;
        }
        return ;
    }

    int mid=MID(f[pos].le,f[pos].ri);
    if(mid>=le)
        update(L(pos),le,ri);
    else
        update(R(pos),le,ri);
   pushup(pos);
}

stud query(int pos,int le,int ri)
{
    if(f[pos].le==le&&f[pos].ri==ri)
    {
       return f[pos];
    }

    int mid=MID(f[pos].le,f[pos].ri);
    if(mid>=ri)
        return query(L(pos),le,ri);
    else
        if(mid<le)
        return query(R(pos),le,ri);
    else
    {
        stud te=query(L(pos),le,mid);
        stud he=query(R(pos),mid+1,ri);
        stud ans;
        ans.a[0][0]=Max(Max(Max(te.a[0][0],he.a[0][0]),te.a[0][1]+he.a[0][0]),te.a[0][0]+he.a[1][0]);
        ans.a[0][1]=Max(Max(Max(te.a[0][1],he.a[0][1]),te.a[0][1]+he.a[0][1]),te.a[0][0]+he.a[1][1]);
        ans.a[1][0]=Max(Max(Max(te.a[1][0],he.a[1][0]),te.a[1][1]+he.a[0][0]),te.a[1][0]+he.a[1][0]);
        ans.a[1][1]=Max(Max(Max(te.a[1][1],he.a[1][1]),te.a[1][1]+he.a[0][1]),te.a[1][0]+he.a[1][1]);
        return ans;
    }

}

void build(int pos,int le,int ri)
{
    f[pos].le=le;
    f[pos].ri=ri;
    if(le==ri)
    {
        if(le&1)
        {
            f[pos].a[1][1]=a[le];
            f[pos].a[0][0]=INF;
            f[pos].a[0][1]=f[pos].a[1][0]=INF;
        }
        else
        {
            f[pos].a[0][0]=a[le];
            f[pos].a[0][1]=f[pos].a[1][0]=f[pos].a[1][1]=INF;
        }
        return ;
    }
    int mid=MID(le,ri);
    build(L(pos),le,mid);
    build(R(pos),mid+1,ri);
    pushup(pos);
}

int main()
{
    int i,j,t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(i=1;i<=n;i++)
            scanf("%lld",&a[i]);
        build(1,1,n);
        int op,le,ri;
        while(m--)
        {
            scanf("%d%d%d",&op,&le,&ri);

            if(op==0)
            {

                stud temp=query(1,le,ri);
                ll ans=temp.a[0][0];
                for(i=0;i<2;i++)
                    for(j=0;j<2;j++)
                      ans=Max(ans,temp.a[i][j]);
                printf("%lld\n",ans);
            }
            else
            {
                update(1,le,ri);
            }
        }
    }
    return 0;
}

/*

5
5 3
-6 -8 3 4 5
0 1 5
1 4 -2
0 1 5

*/

/*

超时代码

*/

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)
typedef long long ll;
#define bug printf("hi\n")
#define INF -1000000005
#define N 100005

inline ll Max(ll x,ll y)
{
    return x>y?x:y;
}

struct stud{
  int le,ri;
  ll a[2][2];
}f[N*4];

ll a[N];
int n,m;

void pushup(int pos)
{
   f[pos].a[0][0]=Max(f[L(pos)].a[0][0],f[R(pos)].a[0][0]);
   f[pos].a[0][0]=Max(f[pos].a[0][0],f[L(pos)].a[0][0]+f[R(pos)].a[1][0]);
   f[pos].a[0][0]=Max(f[pos].a[0][0],f[L(pos)].a[0][1]+f[R(pos)].a[0][0]);

   f[pos].a[0][1]=Max(f[L(pos)].a[0][1],f[R(pos)].a[0][1]);
   f[pos].a[0][1]=Max(f[pos].a[0][1],f[L(pos)].a[0][0]+f[R(pos)].a[1][1]);
   f[pos].a[0][1]=Max(f[pos].a[0][1],f[L(pos)].a[0][1]+f[R(pos)].a[0][1]);

   f[pos].a[1][0]=Max(f[L(pos)].a[1][0],f[R(pos)].a[1][0]);
   f[pos].a[1][0]=Max(f[pos].a[1][0],f[L(pos)].a[1][0]+f[R(pos)].a[1][0]);
   f[pos].a[1][0]=Max(f[pos].a[1][0],f[L(pos)].a[1][1]+f[R(pos)].a[0][0]);

   f[pos].a[1][1]=Max(f[L(pos)].a[1][1],f[R(pos)].a[1][1]);
   f[pos].a[1][1]=Max(f[pos].a[1][1],f[L(pos)].a[1][0]+f[R(pos)].a[1][1]);
   f[pos].a[1][1]=Max(f[pos].a[1][1],f[L(pos)].a[1][1]+f[R(pos)].a[0][1]);
}

void update(int pos,int le,int ri)
{
    if(f[pos].le==le&&f[pos].ri==le)
    {
        if(le&1)
        {
            f[pos].a[1][1]=ri;
            f[pos].a[0][0]=INF;
            f[pos].a[0][1]=f[pos].a[1][0]=INF;
        }
        else
        {
            f[pos].a[0][0]=ri;
            f[pos].a[0][1]=f[pos].a[1][0]=f[pos].a[1][1]=INF;
        }
        return ;
    }

    int mid=MID(f[pos].le,f[pos].ri);
    if(mid>=le)
        update(L(pos),le,ri);
    else
        update(R(pos),le,ri);
   pushup(pos);
}

ll query(int pos,int le,int ri,int s,int e)
{
    if(f[pos].le==le&&f[pos].ri==ri)
    {
       return f[pos].a[s][e];
    }

    int mid=MID(f[pos].le,f[pos].ri);
    if(mid>=ri)
        return query(L(pos),le,ri,s,e);
    else
        if(mid<le)
        return query(R(pos),le,ri,s,e);
    else
    {
        ll temp=query(L(pos),le,mid,s,s)+query(R(pos),mid+1,ri,s^1,e);
        ll hh=query(L(pos),le,mid,s,s^1)+query(R(pos),mid+1,ri,s,e);
        return Max(temp,hh);
    }

}

void build(int pos,int le,int ri)
{
    f[pos].le=le;
    f[pos].ri=ri;
    if(le==ri)
    {
        if(le&1)
        {
            f[pos].a[1][1]=a[le];
            f[pos].a[0][0]=INF;
            f[pos].a[0][1]=f[pos].a[1][0]=INF;
        }
        else
        {
            f[pos].a[0][0]=a[le];
            f[pos].a[0][1]=f[pos].a[1][0]=f[pos].a[1][1]=INF;
        }
        return ;
    }
    int mid=MID(le,ri);
    build(L(pos),le,mid);
    build(R(pos),mid+1,ri);
    pushup(pos);
}

ll dp[105][2];

ll solve(int le,int ri)
{

  int i,j;

  for(i=0;i+le<=ri;i++) dp[i][0]=dp[i][1]=INF;
  if((le%2)==0)
  {
      dp[0][0]=a[le];
      dp[0][1]=INF;
  }
  else
  {
     dp[0][0]=INF;
     dp[0][1]=a[le];
  }

  for(i=le+1;i<=ri;i++)
  {
     if(i&1)
     {
         dp[i-le][0]=dp[i-1-le][0];
         dp[i-le][1]=max(max(dp[i-le-1][0]+a[i],dp[i-le-1][1]),a[i]);
     }
     else
     {
         dp[i-le][1]=dp[i-le-1][1];
         dp[i-le][0]=max(max(dp[i-le-1][1]+a[i],dp[i-le-1][0]),a[i]);
     }
  }

  return max(dp[ri-le][0],dp[ri-le][1]);
}

int main()
{
    int i,j,t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(i=1;i<=n;i++)
            scanf("%lld",&a[i]);
        build(1,1,n);
        int op,le,ri;
        while(m--)
        {
            scanf("%d%d%d",&op,&le,&ri);
            ri=min(n,ri);


            if(op==0)
            {
                int len=ri-le+1;
                if(len<=100)
               {
                printf("%lld\n",solve(le,ri));
                continue;
               }
                ll temp=Max(query(1,le,ri,0,0),query(1,le,ri,0,1));
                ll hh=Max(query(1,le,ri,1,0),query(1,le,ri,1,1));
                printf("%I64d\n",Max(temp,hh));
            }
            else
            {
                update(1,le,ri);
                a[le]=ri;
            }
        }
    }
    return 0;
}

/*

5
5 3
-6 -8 3 4 5
0 1 5
1 4 -2
0 1 5

*/




MIPI D-PHY TX 一致性测试实例解析 Part 01 续 本文为MIPI D-PHY TX一致性测试实例解析part01章节的第二部分 阅读详情

相关推荐

美团mtgsig 3.1.0算法还原:从加密入口到d1生成的完整链路拆解

本文详细拆解了美团mtgsig 3.1.0签名算法的完整逆向过程。通过定位加密入口函数eH,理清a6、a5、a8到d1的生成依赖链,并运用插桩技术,在JSVMP混淆环境下逐步还原了核心参数的生成逻辑,为逆向工程实践提供了清晰的纯算还原方法论。

oo7890的博客 777

Subsequence

Description A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the min...

weixin_34228617的博客 263

高效复用PCB设计:Cadence Sub-Drawing跨项目复制技巧

本文详细介绍了Cadence Allegro中Sub-Drawing功能的应用技巧,帮助PCB工程师高效复用成熟设计模块。通过分步教学,从精准导出到完美导入,并提供了解决坐标错位与DRC冲突的实用避坑指南。掌握这一技巧能显著提升设计效率,实现团队知识的标准化积累与快速复用。

weixin_29172201的博客 395

Codeforces 888E:Maximum Subsequence(枚举,二分)

You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices \(b_1, b_2, ..., b_k (1 ≤ b_1 < b_2 < ... < b_k ≤ n)\) in su...

weixin_38168081的博客 330

WPS Office 2019 For Linux二次开发全流程:从源码下载到Demo运行

本文详细介绍了在Linux环境下进行WPS Office 2019 C++二次开发的全流程,涵盖从开发环境准备、源码获取、核心依赖(Qt与WPS)安装配置,到最终编译运行官方Demo的完整步骤。文章重点解析了环境搭建中的常见问题与解决方案,旨在帮助开发者快速上手WPS二次开发。

weixin_29001423的博客 388

离线环境下 Ubuntu 22.04 制作自定义apt源 安装 Docker环境 的部署方案

本文介绍了一种在无外网环境下部署服务器项目的离线方案。通过在外网环境中制作包含APT软件包和Docker镜像的离线资源包,实现在内网环境中的完整部署。方案详细说明了离线APT源的制作方法、Docker镜像的导出/导入流程,以及内网服务器的软件安装和网络配置步骤。特别强调了版本一致性、目录结构规范和网络适配等注意事项,适用于需要严格隔离网络的生产环境部署。该方案具有可扩展性,可根据实际需求调整软件包和镜像列表。

mmx_2022的博客 654

hdu 1159Common Subsequence(dp 最大不连续的子序列)

Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 32764    Accepted Submission(s): 14828 Problem Description A s

GreyWings的博客 447

ctf——writeup

ctf线上赛——第三关地址:http://106.75.86.18:2222提示:ip spoofing——ip伪造首先访问目标地址,一个正常的网页,挺文艺的。上面有些提示。根据上面的提示,我们浏览网页。找了好久,终于找到你。这个跳转链接。(在这个页面下方)我们接着点击这个链接,就跳转到administrator.php这个页面了。看到这个登录页面,就要知道用户名,密码,可是没有怎么办。一开始也试

Child_by_dream的博客 1320

[线段树]hdu5316

题意: 给出两种操作,一种是求区间漂亮子序列的和的最大值,另一个就是给指定的点改变值。 题目中最重要的一句话:A beautiful subsequence is a subsequence that all the adjacent pairs of elves in the sequence have a different parity of position.

zylm的专栏 804

从零构建安全通信:mbedtls与ECDSA在嵌入式系统中的实战指南

本文详细介绍了如何在嵌入式系统中使用mbedtls和ECDSA实现安全通信,重点探讨了ECDSA相比RSA的优势、mbedtls的模块化裁剪策略、密钥安全存储方案以及完整的签名验签流程。通过实战案例和优化技巧,帮助开发者在资源受限环境下构建高效可靠的安全通信系统。

weixin_28338005的博客 685

【Docker安装】OpenEuler系统下部署Docker环境

【Docker安装】OpenEuler系统下部署Docker环境

jks212454的博客 4189

[HDU6155]Subsequence Count(线段树+矩阵)

DP式很容易得到,发现是线性递推形式,于是可以矩阵加速。又由于是区间形式,所以用线段树维护。 https://www.cnblogs.com/Miracevin/p/9124511.html 关键在于证明区间操作中,可以直接在打标记的位置翻转矩阵两行两列。 上面网址用代数形式证了一遍,这里考虑从矩阵本身解释。 由线代内容可知,将一个矩阵作初等行变换,相当于将其左乘一个作了相应初等列变换的单...

weixin_30430169的博客 193

Android功耗系列专题分析之四:待机概率性功耗高的失效分析

本文分析了Android设备待机功耗异常高的问题。通过日志发现系统休眠失败,原因是PowerManagerService.Display唤醒锁未被释放。进一步排查发现,指纹解锁功能在灭屏时未正确释放屏幕锁定,导致DisplayReady状态异常。解决方案是将指纹功能的背光控制与DisplayReady状态控制分离,使用两个变量独立管理。经验表明,快速定位问题比解决问题更重要,修改原生流程时需谨慎评估风险。

451

hdu 5316 Magician(线段树)

题目链接:hdu 5316 Magician 线段树,区间合并,每个节点维护两端位置分别为奇奇,奇偶,偶奇,偶偶的beautiful 子串,合并的时候注意不能为空即可。 #include #include #include using namespace std; typedef long long ll; const int maxn = 100005; const

不慌不忙、不急不躁 703

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

HDU 5316 Magician (线段树)

题目链接:HDU 5316 Magician 题意:给出n个数的序列,有两种操作:0 a b表示询问[a,b]区间中美丽子序列的最大和,1 a b 表示将a位置上的数修改为b。 美丽子序列的定义是 在原来的序列中挑出几个数组成一个序列要求他们的下标(指的是在原序列中的下标)奇偶性不同。 思路:用线段树维护一个区间中 奇奇,奇偶,偶奇,偶偶四种状态的最大和,其中(奇奇就表示区间两个

n-1 877

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

hdu 5316 Magician (线段树)

题目链接:   hdu 5316 Magician 题目描述:   有n个精灵,每个精灵都有一个魔法值,现在有两个操作:   (0, a, b)查询[a, b]序列中的一个完美序列的最大和,完美序列就是数组中相邻数字的下标奇偶性不同。   (1, a, b)更新下标为a的精灵魔法值为b。 对的,没错就是这个意思,但是比赛的时候就是题意卡的死死的有没有啊,就是各种不懂有没有啊!!! ...

weixin_30896763的博客 90

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

【HDU 5316 Magician】线段树 奇偶和

HDU 5316 题意 给你n个元素的序列 1操作 把第 l 个元素值改成 r 0操作 求 l 到 r 满足一个序列期中每个相邻元素在原序列中坐标奇偶性不同的最大和 一开始我的做法 是求坐标为奇的最大连续一段和 坐标为偶的最大一段连续和 两个相加即可 后来想了下题目可以断开加和 所以我这个做法显然是错误的 我们应该维护四个东西 就是维护起始坐标为偶(奇) 终止坐标为偶(奇)的情况合并即可 注意因为...

我是谁 --- 卡比兽 293

hdu 5316 Magician 线段树

Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an innate talent, gaining it through study and practice, or receiving it from another being, often a g

纳兰 489

【HDU 5316】Magician(线段树)

一开始度错题了,题意是求一段和最大的【子序列】,要求相邻两个元素的位置必须互为奇偶。 这样我们可以使用线段树维护4个值: 一段区间内开头结尾元素为: 奇奇 奇偶 偶奇 偶偶 的最大值 之后在pushup的的时候根据题目所给的意思进行合并。 #include #include #include using namespace std; #define lson (pos<<1) #

花月阁 751

HDU5316 Magician 线段树区间合并

传送门:HDU5316 Magician Time Limit: 18000/9000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Fantasy magicians usually gain their ability through one of three

上决╇ф的ACM 569

hdu 5316 Magician 线段树

2015Multi-UniversityTrainingContest3 1001 1 #include "bits/stdc++.h" 2 using namespace std; 3 #define M 100010 4 #define lson l,m,rt<<1 5 #define rson m+1,r,rt<<...

diufeng0879的博客 200

【线段树】HDU 5316 Magician

通道 题意:n个数,2种操作,1是单点更新,2是询问区间内序号为奇偶交错的和。 代码: 1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include <iostream> 3 #include <fstream> 4 #include <str...

142

hdu 5316 Magician (线段树)

/* 题意:求一个区间内的最大的子序列的和:要求必须子序列中相邻的数下标奇偶性不同。 维护区间内的 开始奇结束偶 开始奇结束奇 开始偶结束奇 开始偶结束偶 */ # include # include # include using namespace std; # define lson l,m,rt<<1 # define rson m+1,r,rt<<1|1 # define

苍竹林 515

HDU5316 Magician(线段树)

/** 题意:一个初始序列A, 长度为n, 有m个操作, 操作两种: 0 l r 求区间的一个子序列, 子序列需要满足其下标奇偶性交互,求其最大值 1 x y 将A[x] 赋值为 y 思路: 求区间最大值, 一般想到是线段树, 但是这个怎么维护呢?我们想到既然是求子序列, 那么我们应该也是维护线段树中 每个节点的下标奇偶性交互的序列最大值, 但是怎么合并呢? 既然是奇偶性交互,那么可以维护区间中

hnust_Derker的博客 363

hdu5316Magician 线段树

//1 a b 将a位置的数改为b //0 a b 输出[a,b] 区间内的 maximum sum of beautiful subsequence //A beautiful subsequence is a subsequence that all the adjacent pairs //of elves in the sequence have a different parity of

ijbuhv的专栏 916
上一篇: HDU 1025 Constructing Roads In JGShining's Kingdom(LIS +二分)
下一篇: hdu 5317 RGCDQ
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值