Uva_105 (类并查集)
生活随笔
收集整理的这篇文章主要介绍了
Uva_105 (类并查集)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
题目连接:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=41
题解:
类似于数据结构中并查集
AC CODE
#include <iostream> #include <cstdio> using namespace std; int sky[10001] = {0}; int Left = 10001,Right = 0; int main() { // freopen("input.txt","r",stdin); int L,H,R; while (cin >> L >> H >> R) { //构造sky[L...R]区间内的轮廓 for (int i = L; i != R; i++) sky[i] = sky[i] > H ? sky[i] : H; Left = Left < L ? Left : L; Right = Right > R ? Right : R; } while (Left < Right) { // 输出其X下标值 cout << Left << ' '; // 找出不相等的高度值 while (sky[Left] == sky[Left+1]) Left++; cout << sky[Left] << ' '; Left++; } cout << Right << " " << 0 << endl; }转载于:https://blog.51cto.com/zhujifang/1380278
总结
以上是生活随笔为你收集整理的Uva_105 (类并查集)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Flex scroller皮肤的使用
- 下一篇: blog链接