Submission #1266159

#TimeUsernameProblemLanguageResultExecution timeMemory
1266159dhuyyyytrapezoid (balkan11_trapezoid)C++20
2 / 100
81 ms30908 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;

using ll = long long;
using ii = pair<int,int>;
using pii = pair<int,ii>;
using aa = array<int,4>;

const int N = 2e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n,ans = 1,dp[N];

aa p[N];

vector <int> compress;

struct SMT{
    int n;
    vector<int> t;
    vector<int> lazy;
    SMT(int _n = 0) : n(_n){
        t.assign((n << 2),0);
        lazy.assign((n << 2),0);
    }
    void push(int id,int l,int r){
        if (l == r || !lazy[id]) return;
        for (int i = 0; i <= 1; i++){
            t[id*2+i] += lazy[id];
            lazy[id*2+i] += lazy[id];
        }
        lazy[id] = 0;
    }
    void update(int id,int l,int r,int pos,int val){
        if (r < pos || l > pos) return;
        if (l == r){
            t[id] = max(t[id],val);
            return;
        }
        int mid = (l + r) >> 1;
        update(id*2,l,mid,pos,val);
        update(id*2+1,mid+1,r,pos,val);
        t[id] = max(t[id * 2],t[id * 2 + 1]);
    }
    int get(int id,int l,int r,int u,int v){
        if (r < u || l > v) return (int)-1e18;
        if (u <= l && r <= v) return t[id];
        int mid = (l + r) >> 1;
        return max(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
    }
};
int calc(int val){
    return lower_bound(compress.begin(),compress.end(),val) - compress.begin() + 1;
}
/*
p[i][0]: l
p[i][1]: r
p[i][2]: l1
p[i][3]: r1
*/

bool cmp(aa a,aa b){
    return a[1] < b[0];
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= 3; j++){
            cin >> p[i][j];
            if (j >= 2) compress.push_back(p[i][j]);
        }
    }
    sort(p+1,p+1+n,cmp);
    sort(compress.begin(),compress.end());
    compress.erase(unique(compress.begin(),compress.end()),compress.end());
    int m = (int)compress.size();
    SMT tnm(m);
    SMT tree(m);
    for (int i = 1; i <= n; i++){
        dp[i] = tnm.get(1,1,m,1,calc(p[i][2])) + 1;
        tnm.update(1,1,m,calc(p[i][3]),dp[i]);
        ans = max(ans,dp[i]);
    }
    cout << ans << ' ' << 0;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...