Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int dist(int x, int y) {
- x = fabs(x);
- y = fabs(y);
- return x + y;
- }
- int flg = 0;
- int cart_plane[400][400];
- //unique_ptr<int[][40000]> cart_plane{ new int[40000][40000] };
- void cell_visit_count(int xl, int yl, int xh, int yh) {
- xl += 200;
- yl += 200;
- xh += 200;
- yh += 200;
- for(int j = xl; j < xh; j++) {
- for(int k = yl; k < yh; k++) {
- cart_plane[j][k]++;
- if(cart_plane[j][k] > 1)
- flg = 1;
- }
- }
- }
- int main(int argc, char const *argv[])
- {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- int nf; //number of floors
- cin >> nf;
- for (int i = 0; i < nf; ++i)
- {
- for(int j = 0; j < 400; j++) {
- for(int k = 0; k < 400; k++) {
- cart_plane[j][k] = 0;
- }
- }
- flg = 0;
- int fl_len, fl_wid; //len & width of the floor
- cin >> fl_len >> fl_wid;
- int tn; //number of tiles
- cin >> tn;
- int xl[tn], yl[tn],
- xh[tn], yh[tn]; //dimentions of the tiles
- int min_xl = 40000, min_yl = 40000,
- max_xh = -40000, max_yh = -40000,
- flag_ovrlp = 0;
- for(int j = 0; j < tn; j++) {
- cin >> xl[j] >> yl[j] >> xh[j] >> yh[j];
- if (xl[j] < min_xl)
- min_xl = xl[j];
- if (yl[j] < min_yl)
- min_yl = yl[j];
- if (max_xh < xh[j])
- max_xh = xh[j];
- if (max_yh < yh[j])
- max_yh = yh[j];
- cell_visit_count(xl[j], yl[j], xh[j], yh[j]);
- }
- if(flg == 1) {
- cout << "NONDISJOINT" << endl;
- }
- else if (dist(min_xl, max_xh) > fl_len || dist(min_yl, max_yh) > fl_wid)
- cout << "NONCONTAINED" << endl;
- }
- return 0;
- }
- //NONCOVERING
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement