EWTD

Untitled

Oct 16th, 2020
702
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<math.h>
  3. #define max(a,b) \
  4.    ({ __typeof__ (a) _a = (a); \
  5.        __typeof__ (b) _b = (b); \
  6.      _a > _b ? _a : _b; })
  7. #define min(a,b) \
  8.    ({ __typeof__ (a) _a = (a); \
  9.        __typeof__ (b) _b = (b); \
  10.      _a < _b ? _a : _b; })    
  11. int main(){
  12.     int n;
  13.     scanf("%d",&n);
  14.     long l_border, r_border;
  15.     long x, y;
  16.     scanf("%ld %ld",&l_border, &r_border);
  17.     while(2 == scanf("%ld %ld", &x, &y)){
  18.         //printf("x:%ld, y:%ld, l_border:%ld, r_border:%ld, x>r_border:%d, y < l_border:%d\n",x,y,l_border,r_border,x>r_border,y<l_border);
  19.         if (x > r_border+1 || y < l_border-1){
  20.             printf("%ld %ld\n",l_border,r_border);
  21.             l_border = x;
  22.             r_border = y;
  23.             continue;
  24.         }
  25.         r_border = max(r_border,y);
  26.         l_border = min(l_border,x);
  27.     }
  28.     printf("%ld %ld\n",l_border,r_border);
  29.     return 0;
  30. }
RAW Paste Data