Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<ll, ll> pii;
- #define fi first
- #define se second
- #define mp make_pair
- vector<int> xc, yc, sx, sy;
- const int N = (int)1e5 + 9;
- int cnt1[N], cnt2[N], cnt3[N], cnt4[N];
- set<int> c1, c2, c3, c4;
- int main(){
- int n;
- scanf("%d", &n);
- char ty[n];
- int x1[n];
- int y1[n];
- int x2[n];
- int y2[n];
- for(int i = 0 ;i < n; i ++ ){
- cin >> ty[i];
- scanf("%d %d %d %d", &x1[i], &y1[i], &x2[i], &y2[i]);
- xc.push_back(x1[i]);
- yc.push_back(y1[i]);
- sx.push_back(x2[i]);
- sy.push_back(y2[i]);
- }
- sort(xc.begin(), xc.end());
- sort(yc.begin(), yc.end());
- sort(sx.begin(), sx.end());
- sort(sy.begin(), sy.end());
- xc.resize(unique(xc.begin(), xc.end()) - xc.begin());
- yc.resize(unique(yc.begin(), yc.end()) - yc.begin());
- sx.resize(unique(sx.begin(), sx.end()) - sx.begin());
- sy.resize(unique(sy.begin(), sy.end()) - sy.begin());
- int s1, s2;
- ll answ;
- for(int i = 0 ; i < n; i ++ ){
- x1[i] = lower_bound(xc.begin(), xc.end(), x1[i]) - xc.begin();
- y1[i] = lower_bound(yc.begin(), yc.end(), y1[i]) - yc.begin();
- x2[i] = lower_bound(sx.begin(), sx.end(), x2[i]) - sx.begin();
- y2[i] = lower_bound(sy.begin(), sy.end(), y2[i]) - sy.begin();
- if(ty[i] == '+'){
- cnt1[x1[i]] ++ ;
- if(cnt1[x1[i]] == 1)
- c1.insert(x1[i]);
- cnt2[y1[i]] ++ ;
- if(cnt2[y1[i]] == 1)
- c2.insert(y1[i]);
- cnt3[x2[i]] ++ ;
- if(cnt3[x2[i]] == 1)
- c3.insert(x2[i]);
- cnt4[y2[i]] ++ ;
- if(cnt4[y2[i]] == 1)
- c4.insert(y2[i]);
- }
- else{
- cnt1[x1[i]] -- ;
- if(cnt1[x1[i]] == 0)
- c1.erase(x1[i]);
- cnt2[y1[i]] -- ;
- if(cnt2[y1[i]] == 0)
- c2.erase(y1[i]);
- cnt3[x2[i]] -- ;
- if(cnt3[x2[i]] == 0)
- c3.erase(x2[i]);
- cnt4[y2[i]] -- ;
- if(cnt4[y2[i]] == 0)
- c4.erase(y2[i]);
- }
- if(c1.empty() || c2.empty() || c3.empty() || c4.empty()){
- printf("0\n");
- continue;
- }
- auto it = c3.begin();
- s1 = sx[*it];
- it = c1.end();
- -- it;
- s1 -= xc[*it];
- // !!!!!!!!!!!!!!!1
- it = c4.begin();
- s2 = sy[*it];
- it = c2.end();
- -- it;
- s2 -= yc[*it];
- answ = 1ll * s1 * s2;
- answ = max(answ, 0ll);
- printf("%lli\n", answ);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement