返回顶部
摘要: 定义 树状数组是一个查询和修改复杂度都为log(n)的数据结构。主要用于查 询任意区间的连续元素和,但是每次只能修改一个元素的值;即树状数 组支持的操作:单点修改,区间查询(当区间长度为1时,即单点查询) 树状数组逻辑上是一棵树,但实际上只是一个数组。 设C的某个元素下标为x,则这个结点(前缀和)的 阅读全文
posted @ 2024-02-19 18:35 wlesq 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 单点修改 区间查询 点击查看代码 #include <iostream> #include <cstdio> #include <algorithm> #include <math.h> #include <string.h> #include <string> #include <cstring> 阅读全文
posted @ 2024-02-19 11:22 wlesq 阅读(1) 评论(0) 推荐(0) 编辑
摘要: Vjudge 看数据范围很大,开数组会超内存,此题需要离散化 常见离散化 for(int i=1;i<=n;i++) { scanf("%lld",&v[i].v); v[i].id=i; } sort(v+1,v+1+n,cmpv); int cnt=1; for(int i=2;i<=n;i++ 阅读全文
posted @ 2024-02-19 09:49 wlesq 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Making the Grade Vjudge 题目描述:A straight dirt road connects two fields on FJ's farm, but it changes elevation more than FJ would like. His cows do not 阅读全文
posted @ 2024-02-19 07:45 wlesq 阅读(4) 评论(0) 推荐(0) 编辑