首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >计算不同图层的顶视图

计算不同图层的顶视图
EN

Stack Overflow用户
提问于 2017-08-12 23:48:29
回答 1查看 41关注 0票数 0

我正在尝试即兴解决这个问题,我们给出了不同的层,每个层都有离散范围之间的交错颜色,我们必须计算这些层的俯视图。准确地说,它是如何将不同的层投影到一个层中的。

例如,

到目前为止,我几乎没有什么见解,

代码语言:javascript
复制
We need to sort these segments based on ending points (so that I can
sweep linearly from 0 to 6)

Split these sorted items into unit intervals. eg. 0-1 (black), 0-1
(red), 1-2 (red), 2-3 (black), 2-3(green), 3-4 (green), 3-4 (red),
4-5 (red), 5-6 (black)

Push each interval into hashmap and update the color for hashmap for
given interval if it is in a upper layer.

eg. if we push 0-1 (red) (at layer 0) and we encounter 0-1 (black)
(at layer 2) we update map with key 0-1 to black. 

Print the map values.

从第二步开始,有什么想法可以即兴发挥吗?

EN

回答 1

Stack Overflow用户

发布于 2017-08-13 00:10:52

这个问题就像SPOJ上的this问题一样,可以通过分段树或二叉树来有效地解决,你可以参考this的博客或者通过this讨论

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45652149

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档