lightoj 1085 树状数组+dp

快速入门:使用 SQL Server Management Studio (SSMS) 连接和查询 SQL Server 实例 开始使用 SQL Server Management Studio (SSMS) 连接到 SQL Server 实例并运行一些 Transact-SQL (T-SQL) 命令。本文介绍如何连接和查询实例SQL Server。有关 Azure SQL,请参阅连接。若要使用,请参阅连接和查询。若要详细了解如何SQL Server Management Studio,请参阅其他。...... 阅读详情

Description
Given a binary number, we are about to do some operations on the number. Two types of operations can be here.

‘I i j’ which means invert the bit from i to j (inclusive)
‘Q i’ answer whether the ith bit is 0 or 1

The MSB (most significant bit) is the first bit (i.e. i=1). The binary number can contain leading zeroes.

Input
Input starts with an integer T (≤ 10), denoting the number of test cases.

Each case starts with a line containing a binary integer having length n (1 ≤ n ≤ 105). The next line will contain an integer q (1 ≤ q ≤ 50000) denoting the number of queries. Each query will be either in the form ‘I i j’ where i, j are integers and 1 ≤ i ≤ j ≤ n. Or the query will be in the form ‘Q i’ where i is an integer and 1 ≤ i ≤ n.

Output
For each case, print the case number in a single line. Then for each query ‘Q i’ you have to print 1 or 0 depending on the ith bit.

Sample Input
2
0011001100
6
I 1 10
I 2 7Description
An increasing subsequence from a sequence A1, A2 … An is defined by Ai1, Ai2 … Aik, where the following properties hold

  1. i1 < i2 < i3 < … < ik and
  2. Ai1 < Ai2 < Ai3 < … < Aik

Now you are given a sequence, you have to find the number of all possible increasing subsequences.

Input
Input starts with an integer T (≤ 10), denoting the number of test cases.

Each case contains an integer n (1 ≤ n ≤ 105) denoting the number of elements in the initial sequence. The next line will contain n integers separated by spaces, denoting the elements of the sequence. Each of these integers will be fit into a 32 bit signed integer.

Output
For each case of input, print the case number and the number of possible increasing subsequences modulo 1000000007.

Sample Input
3
3
1 1 2
5
1 2 1000 1000 1001
3
1 10 11
Sample Output
Case 1: 5
Case 2: 23
Case 3: 7

这个题,讲道理单纯作为一个dp来讲
弱智的一匹
但是学长们把它放在树状数组专题测试里面
这就很诡异了
想了一会发现没啥思路….
看看剩下其他俩题卧槽都不会…这就很尴尬了….
然后按照寻常dp的思路想了想发现了一点东西….
按照最垃圾的那种dp做法这个题应该是每一个都从前面转移,
从前向后的一个过程…..
但是10^5的数据量n^2不炸就不对了….
然后就突然看到了这个求和的过程…
既然是求和的一个过程那么就很好理解了….
用把自己转移到其他可达状态的那种写法
nlgn勉强写出来了….
然后还有一点是xjb写的,比如那个排序为什么一样大是大序号在前我也不知道
一发不过xjb改反正就这么写完就是能过….
等想明白了补充….

#include<iostream>
#include<memory.h>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;
int lowbit(int x) 
{
    return x&-x;
}
int ga[100001];
int c[100001];
int n, m;
int sss[100000];
int gs(int x)
{
    int q = 0;
    for (int y = x;y > 0;y -= lowbit(y))q += c[y],q%=1000000007;
    return q;
}
void gengxin(int xiabiao, int zhi)
{
    for (int q = xiabiao;q <= n;q += lowbit(q))
    {
        c[q] += zhi;
        c[q] %= 1000000007;
        //if (c[q] < 0)c[q] = 0;
    }
}
int asasa(int qqw, int wwe)
{
    if (ga[qqw] != ga[wwe])return ga[qqw] < ga[wwe];
    else return qqw > wwe;
}
int main()
{
    int T;
    cin >> T;
    int u = 0;
    while (T--)
    {
        memset(c, 0, sizeof(c));
        memset(sss, 0, sizeof(sss));
        cin >> n;
        for (int a = 1;a <= n;a++)scanf("%d", &ga[a]), sss[a]=a;
        sort(sss + 1, sss + 1 + n,asasa);
        for (int a = 1;a <= n;a++)gengxin(sss[a], gs(sss[a])+1);
        printf("Case %d: %d\n", ++u, gs(n));
    }
    return 0;
}
Flowable第一篇、快速上手(Flowable安装、配置、集成) Flowable是一个轻量级、高效可扩展的工作流和业务流程管理(BPM)引擎,支持在Java应用程序中实现复杂的工作流自动化。Flowable最初是作为Activiti项目的一个分支发展而来的,但它现在已经成为一个独立的开源项目,并在企业级应用中得到了广泛使用 阅读详情

相关推荐

阿里系acw_sc__v3滑块验证码逆向分析与实战破解

本文深入解析阿里系acw_sc__v3滑块验证码的核心机制与逆向破解方法。通过分析加密参数生成、轨迹验证模块和动态加密策略,提供完整的自动化破解方案,包括设备指纹生成、缺口识别和轨迹加密等关键技术。文章还分享了常见问题的调试技巧,帮助开发者应对阿里系验证码的复杂防护体系。

wdx012345的博客 1885

LightOJ 1080 - Binary Simulation (树状数组)

1080 - Binary Simulation     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 64 MB Given a binary number, we are about to do some operatio

Calm微笑 539

NE564锁相环FM解调电路设计:10.7MHz中频实测与3种失真优化方案

本文详细解析了NE564锁相环在10.7MHz中频FM解调电路中的设计与优化方案。通过分析锁相环技术基础、电路架构设计及典型失真问题,提供了3种有效的失真优化方法,包括限幅增强、VCO频偏补偿和环路滤波优化,显著提升解调性能。文章还涵盖了PCB布局要点和系统测试验证,为高频电子线路设计提供实用参考。

weixin_33314040的博客 360

Light OJ 1080 - Binary Simulation - (线段树区间更新 单点查询)

Description Given a binary number, we are about to do some operations on the number. Two types of operations can be here. 'I i j'    which means invert the bit from i to j (inclusive) 'Q i'    a

__ElemenT 1079

Python 逆向解析知乎盐选反爬字体,实现内容精准还原

本文详细解析了知乎盐选内容的反爬字体机制,并提供了使用Python逆向解析WOFF字体文件的完整方案。通过fontTools库构建解码字典,实现乱码文本的精准还原,帮助开发者应对动态字体策略,同时强调法律与道德风险。

weixin_29268385的博客 1321

IMU卡尔曼滤波方法详细介绍

本文介绍了基于IMU和卡尔曼滤波的状态估计方法。系统采用9维状态向量(位置、速度、加速度计零偏),通过牛顿运动学建立状态方程,并利用外部位置观测进行校正。详细推导了状态转移矩阵和控制输入矩阵的形式,阐述了预测和更新的计算步骤。同时说明了过程噪声Q和观测噪声R的设置原则,其中Q反映模型不确定性,R取决于传感器精度。该方法可有效融合IMU测量与外部观测数据,实现位置、速度和偏置的联合估计。

haing2019的博客 765

lightoj 1085 - All Possible Increasing Subsequences 【树状数组优化dp】

1085 - All Possible Increasing Subsequences PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 64 MB An increasing subsequence from a sequen

世界很大 715

电力-平衡式IEC 60870-5-101规约报文解析

本文详细介绍了电力自动化中平衡式IEC 60870-5-101规约的应用,包括链路建立与初始化、对时、遥控操作、数据上送和总召唤等关键步骤,通过实例解析了报文格式和交互过程,是理解配网自动化通信的重要参考资料。

让你爱上电路设计 5703

LightOJ-1085-树状数组,离散化,dp

题目大意:求出一个序列中有多少个递增序列(不需要是连续的)。 题目解析:对于一个以i结尾的,那么dp[i]=sum(dp[j])+1(j AC代码: #include #include #include #include #include using namespace std; const int maxn=100010; const int mod=1000000007; int n,d

zyz_3_14159的博客 355

JavaScript比较与逻辑运算符底层原理详解

JavaScript中的比较运算符(如==、===、>)和逻辑运算符(如&&、||)并非简单返回布尔值,而是基于类型转换规则(ToNumber、ToPrimitive、ToBoolean)执行抽象操作的确定性过程。理解其背后的标准协议——抽象相等比较、严格相等判断、关系运算数值化,以及逻辑运算的短路与原值返回机制,是避免隐式转换陷阱、写出可预测代码的关键。这些机制直接支撑着条件判断、默认值处理、安全访问等高频工程实践,广泛应用于表单校验、API响应处理、状态管理及UI渲染逻辑中。

weixin_32075843的博客 341

OpenMVS :用 colmap制作自己的数据集 重建(用colmap计算位姿,将位姿转为MVS需要的格式)

数据集制作主要是在windows进行,比较方便。

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 3337

Lightoj 1085 All Possible Increasing Subsequences (树状数组+DP)

题目链接:http://lightoj.com/volume_showproblem.php?problem=1085 题意:找出一个序列中的所有上升序列。 思路:离散化后,树状数组优化的DP。dp[i]表示以a[i]为序列最后一个数字的上升序列的个数,状态转移方程见注释。 很久前写的,都快忘了这题是怎么回事了…… #include #include #include #includ

whyorwhnt的专栏 1381

多模型动态路由(Fusion):从“算力霸权”到“架构分权”的工程范式转型

多模型动态路由(Multi-Model Dynamic Routing)是指在多个大语言模型之间,根据请求特征、资源约束和业务目标,动态选择最优模型或模型组合的技术范式。传统网关擅长管理请求流量,但不理解“任务类型”。而AI路由层需要对每个请求进行语义理解、能力匹配和成本评估。从“算力霸权”到“架构分权”,这不是技术的线性演进,而是工程范式的根本转型。过去三年,开发者的核心能力是“选对模型”——在GPT、Claude、Gemini之间做出正确选择。

ZDQ58818的博客 86

LightOJ 1085(树状数组+离散化+DP,线段树)

All Possible Increasing Subsequences Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%lld &amp; %llu Appoint description:  Description An increasing subsequence from a seque...

weixin_33971977的博客 100

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

[树状数组]LightOJ 1085 - All Possible Increasing Subsequences

1085 - All Possible Increasing Subsequences PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 64 MB An increasing subsequence from a sequen

Airarts_的专栏 849

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

lightoj 1085 All Possible Increasing Subsequences(递推式+离散化+树状数组维护)

1085 - All Possible Increasing Subsequences     PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 64 MB An increasing subsequence from a seq

K键盘里的青春K 758

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

lightoj 1085【离散化+树状数组】

题意: 计算一个序列里有多少个上升子序列 思路: 先离散化一下,按照值排序,如果相同的就按照坐标从大到小排序,这样就可以避免重复计算。 树状数组存的是以a[i]结尾的子序列之和; dp[a[i]]=sigma(a[i]-1)+1; OK,还是很简单的;#include <bits/stdc++.h> using namespace std; typedef long long LL; c

ONE MORE TRY 128

Light oj 1085 - All Possible Increasing Subsequences (简单dp + 离散化 + BIT)

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1085 题意: 问你有多少个上升子序列。 思路: dp[i]表示以第i个数结尾的上升序列数量。 1 #include <iostream> 2 #include <cstdio> 3 #include...

weixin_30629653的博客 85

LightOJ 1085

All Possible Increasing SubsequencesTime Limit: 3000MS Memory Limit: 65536KB 64bit IO Format: %lld & %lluDescription An increasing subsequence from a sequence A1, A2 … An is defined by Ai1

ciel_s的博客 340

lightoj 1085 All Possible Increasing Subsequences

树状数组+dp 用树状数组来求和 dp时用dp[i]表示以a[i]为序列最好一个数字的上升序列的个数 其值等于前面所有dp[1-(i-1)]且(a[i-1]小于a[i]的值)的和 #include #include #include #include using namespace std; #define i64 long long const int

yerongsc的专栏 619

LightOJ 1085 树状数组+动态规划

题目链接 记\(dp(i)\)为以第i个结尾的上升子序列的个数,可以得到转移方程 \[dp(i)=\sum_{j=1,\,a[j]<a[i]}^{i-1}dp(j) + 1\] 然后最终的结果就是\(ans = \sum{dp(i)}\),所以求出每一个\(dp(i)\). 直接求复杂度\(O(n^2)\),自然是不行的。因为只和大小的比较有关系,跟数值本身是无关的,所以先将其离散化。变成...

weixin_30284355的博客 128

lightoj刷题日记

提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1; 题目的类型会在这边说明,具体见分页博客; SUM=54; 1000 Greetings from LightOJ 【简单A+B】 1001 Opposite Task 【简单题】 1002Country Roads【搜索题】 1003Drunk【判环】 1004Monkey B...

weixin_30535565的博客 223

lightoj 1031 被区间dp虐哭...看题解才学会

You are playing a two player game. Initially there are n integer numbers in an array and player A and B get chance to take them alternatively. Each player can take one or more numbers from the left or

NineFailure的博客 2840

HDU1024 这压缩真先进...先进的我想跳河

DescriptionNow I think you have got an AC in Ignatius.L’s “Max Sum” problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult probl

NineFailure的博客 1509
上一篇: HDU3652 常规数位dp入门
下一篇: lightoj 1080
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址