Codeforces Beta Round #75 Igloo Skyscraper
来源:互联网 发布:约束满足问题 推荐算法 编辑:程序博客网 时间:2024/05/29 07:36
很不错的一道线段树的题目
在每个节点里面加个线性表,这是关键的操作!
线性表里面是这个节点的范围内,将它按照a数组从小到大排序,接着剔除掉a[i] >= a[j] 并且b[i] >= b[j]这种j
另外还要用到(a[x] - a[y])*(b[z]-b[y])<=(a[y] - a[z])*(b[y]-b[x),把这种y全部删除掉,保证线性表的单调性
接着查找的时候就可以用到二分,即可得出答案
至于时间复杂度
线段树每一层的线性表里面总共n个点,总共lgn层,每一层都有排序什么的,建树的时间复杂度是O(n lg^2 n)
另外查询有q次,每次递归找区间是lgn次,二分是lgn次,查询的时间是O(q lg ^2 n)
总的时间复杂度是O(n lg^2 n + q lg ^2 n)
还有一点,可以不使用二分,将时间点排序,接着的话,就是最多nlgn次
- Codeforces Beta Round #75 Igloo Skyscraper
- Codeforces Beta Round #2
- Codeforces Beta Round #24
- Codeforces Beta Round #64
- Codeforces Beta Round #23
- Codeforces Beta Round #88
- Codeforces Beta Round #88
- Codeforces Beta Round #91
- Codeforces Beta Round #93
- Codeforces Beta Round #94
- Codeforces Beta Round #95
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #3
- Codeforces Beta Round #10
- Codeforces Beta Round #1
- Codeforces Beta Round #3
- Codeforces Beta Round #8
- 用Tunnelblick在Mac下配置OpenVPN
- 一组经典的JS函数
- 初次接触config文件
- 标准C++类std::string的 内存共享和Copy-On-Write技术
- VC6绿色版中英文双版
- Codeforces Beta Round #75 Igloo Skyscraper
- javaScript打开窗体函数的使用详解和路径转换问题 .
- FTP命令大全
- 《数学之美》有感
- 简化ZXing库Android版
- 破译电脑密码方法
- TPC-C学习笔记
- zarafa-webaccess 更改默认语言和颜色主题
- DOS 常用命令