SHARE
TWEET

Untitled

a guest Apr 20th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int dist(int x, int y) {
  5.     x = fabs(x);
  6.     y = fabs(y);
  7.  
  8.     return x + y;
  9. }
  10.  
  11. int flg = 0;
  12. int cart_plane[400][400];
  13. //unique_ptr<int[][40000]> cart_plane{ new int[40000][40000] };
  14.  
  15. void cell_visit_count(int xl, int yl, int xh, int yh) {
  16.     xl += 200;
  17.     yl += 200;
  18.     xh += 200;
  19.     yh += 200;
  20.  
  21.     for(int j = xl; j < xh; j++) {
  22.             for(int k = yl; k < yh; k++) {
  23.                 cart_plane[j][k]++;
  24.                 if(cart_plane[j][k] > 1)
  25.                     flg = 1;
  26.             }
  27.         }
  28. }
  29.  
  30.  
  31. int main(int argc, char const *argv[])
  32. {
  33.     //freopen("input.txt", "r", stdin);
  34.     //freopen("output.txt", "w", stdout);
  35.  
  36.     int nf; //number of floors
  37.     cin >> nf;
  38.     for (int i = 0; i < nf; ++i)
  39.     {
  40.         for(int j = 0; j < 400; j++) {
  41.             for(int k = 0; k < 400; k++) {
  42.                 cart_plane[j][k] = 0;
  43.             }
  44.         }
  45.         flg = 0;
  46.  
  47.         int fl_len, fl_wid; //len & width of the floor
  48.         cin >> fl_len >> fl_wid;
  49.  
  50.         int tn; //number of tiles
  51.         cin >> tn;
  52.  
  53.         int xl[tn], yl[tn],
  54.             xh[tn], yh[tn]; //dimentions of the tiles
  55.         int min_xl = 40000, min_yl = 40000,
  56.             max_xh = -40000, max_yh = -40000,
  57.             flag_ovrlp = 0;
  58.  
  59.         for(int j = 0; j < tn; j++) {
  60.             cin >> xl[j] >> yl[j] >> xh[j] >> yh[j];
  61.             if (xl[j] < min_xl)
  62.                 min_xl = xl[j];
  63.             if (yl[j] < min_yl)
  64.                 min_yl = yl[j];
  65.             if (max_xh < xh[j])
  66.                 max_xh = xh[j];
  67.             if (max_yh < yh[j])
  68.                 max_yh = yh[j];
  69.  
  70.             cell_visit_count(xl[j], yl[j], xh[j], yh[j]);
  71.  
  72.         }
  73.  
  74.         if(flg == 1) {
  75.             cout << "NONDISJOINT" <<  endl;
  76.         }
  77.  
  78.         else if (dist(min_xl, max_xh) > fl_len || dist(min_yl, max_yh) > fl_wid)
  79.             cout << "NONCONTAINED" << endl;
  80.     }
  81.  
  82.  
  83.     return 0;
  84. }
  85.  
  86. //NONCOVERING
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top