Advertisement
xBloodY

2018/2

Jun 30th, 2022
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct el {
  5.     unsigned x;
  6.     unsigned y;
  7.     el* left = nullptr;
  8.     el* right = nullptr;
  9.     el* prev = nullptr;
  10. };
  11.  
  12. int main() {
  13.     unsigned n, x, y;
  14.     el* tree = nullptr;
  15.     cin >> n;
  16.     for (int i = 0; i < n; i++) {
  17.         cin >> x >> y;
  18.         if (tree != nullptr) {
  19.             el* iter = tree;
  20.             while (iter->next != nullptr && iter->y >= y)
  21.                 iter = iter->next;
  22.         }
  23.         else {
  24.             el tmp = {x, y};
  25.             tree = &tmp;
  26.         }
  27.     }
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement