Submission #1117209

#TimeUsernameProblemLanguageResultExecution timeMemory
1117209vjudge1trapezoid (balkan11_trapezoid)C++17
100 / 100
242 ms27208 KiB
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
pair<int,int> operator+=(pair<int,int> &a,pair<int,int> b){
    if(a.F<b.F)
        return a=b;
    if(a.F>b.F)
        return a;
    a.S+=b.S;
    if(a.S>=30013)
        a.S-=30013;
    return a;
}
struct {
    pair<int,int> trrre[200100]; 
    pair<int,int>query(int x){
        pair<int,int>res;
        while(x)
            res+=trrre[x],x-=x&-x;
        return res;
    }
    void upd(int x,pair<int,int> c){
        c.first++;
        while(x<=2e5)
            trrre[x]+=c,x+=x&-x;
    }
} fenwick;
pair<int,int> vals[100100];
map<int,int>mp2;
map<int,array<int,3>>mp1;
int CC;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        mp2[a],mp2[b];
        mp1[c]={a,0,i};
        mp1[d]={b,1,i};
    }
    fenwick.upd(1,{0,1});
    for(auto&[i,j]:mp2)
        j=++CC;
    for(auto[i,j]:mp1){
        auto[pos,op,ind]=j;
        pos=mp2[pos];
        if(op) fenwick.upd(pos,vals[ind]);
        else vals[ind]=fenwick.query(pos);
    }
    pair<int,int>X = fenwick.query(mp2.size());
    cout<<X.F-1<<' '<<X.S<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...