Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <vector>
- #include <string>
- #include <cmath>
- #include <iomanip>
- #include <algorithm>
- #include <map>
- #include <set>
- #include <deque>
- #include <unordered_map>
- #include <stack>
- #include <queue>
- #include <random>
- #define ll long long
- #define ld long double
- #define mp make_pair
- #define all(v) (v).begin(), (v).end()
- using namespace std;
- const ll inf = 1e18, siz = 2097152; // 2097152
- class node {
- public:
- node() = default;
- ll sum, d;
- node(const ll& sum, const ll& d) {
- this->sum = sum;
- this->d = d;
- }
- };
- vector<node> t(siz * 2 - 1, node(0, 0));
- void run() {
- ll n;
- cin >> n;
- t = vector<node>(siz * 2 - 1, node(0, 0));
- vector<pair<pair<ll, ll>, pair<ll, ll>>> point;
- for (ll i = 0; i < n; i++) {
- ll x1, y1, x2, y2;
- cin >> x1 >> y1 >> x2 >> y2;
- x1 += 1e6;
- x2 += 1e6;
- y1 += 1e6;
- y2 += 1e6;
- pair<pair<ll, ll>, pair<ll, ll>> p1(mp(mp(x1, 1), mp(y1, y2)));
- pair<pair<ll, ll>, pair<ll, ll>> p2(mp(mp(x2, -1), mp(y1, y2)));
- point.push_back(p1);
- point.push_back(p2);
- }
- sort(all(point));
- for (ll i = 0; i < 2 * n; i++) {
- if (point[i].first.second == 1) {
- sum += t[0].sum;
- upd(0, 0, siz, point[i].second.first, point[i].second.second + 1, 1);
- }
- else {
- sum += t[0].sum;
- upd(0, 0, siz, point[i].second.first, point[i].second.second + 1, -1);
- }
- }
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- ll t = 1;
- //cin >> t;
- while (t--) {
- run();
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement