当前位置: 首页 > 网络知识

[HDU4417]Super Mario(主席树+离散化)

时间:2026-01-29 09:27:58

传送门

又是一道主席树模板题,注意数组从0开始,还有主席树耗费空间很大,数组开大点,之前开小了莫名其妙TLE。QAQ

——代码

1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define ls son[now][0], l, mid 5 #define rs son[now][1], mid + 1, r 6 7 using namespace std; 8 9 const int N = 100005; 10 11 int T, n, m, sz, tot, ans; 12 int a[N], b[N], rt[N], son[10 * N][2], sum[10 * N]; 13 14 inline void build(int &now, int l, int r) 15 23 24 inline void update(int &now, int l, int r, int last, int x) 25 35 36 inline void query(int s, int t, int l, int r, int x) 37 43 int mid = (l + r) >> 1; 44 if(x <= mid) query(son[s][0], son[t][0], l, mid, x); 45 else 46 50 } 51 52 inline void clear() 53 61 62 int main() 79 printf("Case %d:\n", ++j); 80 for(i = 1; i <= m; i++) 81 90 else printf("0\n"); 91 } 92 } 93 return 0; 94 }
View Code



上一篇:树的重心
下一篇:[luoguP1119] 灾后重建(Floyd)
离散化 主席树
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素