Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <queue>
- #include <vector>
- #include <set>
- #include <map>
- #include <string>
- #include <cstring>
- #include <ctime>
- #include <utility>
- #include <cassert>
- #include <cmath>
- #include <algorithm>
- #define F first
- #define S second
- #define mp make_pair
- #define pb push_back
- #define fname ""
- using namespace std;
- typedef long long LL;
- typedef pair <int, int> pii;
- const int maxn = (int)700;
- const int inf = (int)2e9;
- const int mod = (int)1e9 + 7;
- const double eps = 1e-9;
- map <int, int> wx, wy;
- int n, c1, c2, d1[maxn][maxn], d2[maxn][maxn], xl[maxn], yl[maxn], xr[maxn], yr[maxn], dx[maxn], dy[maxn], d[maxn][maxn], h, w;
- LL ans, cur;
- int main() {
- freopen(fname"input.txt", "r", stdin);
- freopen(fname"output.txt", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cin >> n;
- for (int i = 1; i <= n; i++)
- {
- cin >> xl[i] >> yl[i] >> xr[i] >> yr[i];
- dx[++c1] = xl[i];
- dx[++c1] = xr[i];
- dy[++c2] = yl[i];
- dy[++c2] = yr[i];
- }
- sort(dx + 1, dx + 1 + c1);
- sort(dy + 1, dy + 1 + c2);
- for (int i = 1; i <= c1; i++)
- {
- if (!wx[dx[i]])
- wx[dx[i]] = ++h;
- }
- for (int i = 1; i <= c2; i++)
- {
- if (!wy[dy[i]])
- wy[dy[i]] = ++w;
- }
- for (int i = 1; i <= n; i++)
- {
- xl[0] = min(wx[xl[i]], wx[xr[i]]);
- xr[0] = max(wx[xl[i]], wx[xr[i]]);
- yl[0] = min(wy[yl[i]], wy[yr[i]]);
- yr[0] = max(wy[yl[i]], wy[yr[i]]);
- if (yl[0] == yr[0])
- xl[0]++;
- if (xl[0] == xr[0])
- yl[0]++;
- for (int v = xl[0]; v <= xr[0]; v++)
- for (int u = yl[0]; u <= yr[0]; u++)
- {
- if (yl[i] != yr[i])
- d1[v][u] = 1;
- if (xl[i] != xr[i])
- d2[v][u] = 1;
- }
- }
- for (int i = 1; i <= h; i++)
- {
- for (int j = 1; j <= w; j++)
- cout << d2[i][j] << " ";
- cout << endl;
- }
- for (int i = 1; i <= h; i++)
- {
- for (int j = 1; j <= w; j++)
- d1[i][j] += d1[i][j - 1];
- }
- for (int l = 1; l <= w; l++)
- {
- for (int r = l + 1; r <= w; r++)
- {
- cur = 0;
- for (int m = 1; m <= h; m++)
- {
- if (!d2[m][l] || !d2[m][r])
- cur = 0;
- ans += cur * ((d1[m][r] - d1[m][l]) == r - l);
- if ((d1[m][r] - d1[m][l]) == r - l)
- cur++;
- }
- }
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement