Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- using namespace std;
- using ll = long long;
- using ld = long double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- struct hpny{
- int y, tp;
- };
- struct hpnx{
- int x,tp; //0-открыл, 1 -закрыл
- hpny y1, y2;
- };
- void shx(hpnx sm){
- cout<<"x = "<<sm.x<<"\n";
- cout<<"type = "<<sm.tp<<"\n";
- cout<<"\n";
- }
- void shy(hpny sm){
- cout<<"y = "<<sm.y<<"\n";
- cout<<"type = "<<sm.tp<<"\n";
- cout<<"\n";
- }
- vector <hpnx> allx;
- vector <hpny> ally;//now
- bool cmpx(hpnx a, hpnx b){
- return a.x < b.x;
- }
- bool cmpy(hpny a, hpny b){
- return a.y < b.y;
- }
- ll ans=0;
- //scan y
- ll scy(int xjn){ //x join
- ll join = 0;
- int bly = 1;
- int y1, y2;
- y1 = ally[0].y1.y;
- for (int i = 1; i < ally.size();++i){
- if (ally[i].tp == 0){
- bly++;
- if (bly == 1){
- y1 = ally[i].y1.y;
- }
- }
- else{
- bly--;
- if (bly == 0){
- y2 = ally[i].y2.y;
- }
- }
- if (bly == 0){
- ans +=
- }
- }
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n; cin>>n;
- for (int i=0;i<n;++i){
- int x1, y1, x2, y2;
- cin>>x1>>y1>>x2>>y2;
- hpnx xl, xr;
- hpny yl, yr;
- yl = {y1, 0};
- yr = {y2, 1};
- xl = {x1, 0, yl, yr};
- xr = {x2, 1, yl, yr};
- allx.push_back(xl);
- allx.push_back(xr);
- }
- sort(allx.begin(), allx.end(), cmpx);
- int blx = 1;
- int x1, x2;
- x1 = allx[0].x;
- ally.push_back(allx[0].y1);
- ally.push_back(allx[0].y2);
- for (int i = 1; i < n * 2; ++i){
- //shx(allx[i]);
- x2 = allx[i].x;
- if (allx[i].tp == 1){
- blx--;
- int id1, id2;
- for (int j = 0; j < ally.size();++j){
- if (ally[j].y == allx[i].y1.y && ally[j].tp == 0){
- id1 = j;
- }
- else if (ally[j].y == allx[i].y2.y && ally[j].tp == 1){
- id2 = j;
- }
- }
- ally.erase(ally.begin() + id1);
- id2--;
- ally.erase(ally.begin() + id2);
- }
- scy(x2 - x1);
- if (allx[i].tp == 0){
- blx++;
- ally.push_back(allx[i].y1);
- ally.push_back(allx[i].y2);
- sort(ally.begin(), ally.end(), cmpy);
- }
- x1 = x2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement