Submission #945620

# Submission time Handle Problem Language Result Execution time Memory
945620 2024-03-14T05:38:34 Z vjudge1 trapezoid (balkan11_trapezoid) C++17
100 / 100
154 ms 15488 KB
#include<bits/stdc++.h>
using namespace std;
struct C{
    int x=0,y=0;
    void operator+=(C z){
        if(x<z.x)
            x=z.x,y=0;
        if(x==z.x)
            y=(y+z.y)%30013;
    }
} T[1<<18],ans[1<<18],res;
map<int,int> mp;
int cnt;
void upd(int x,C z){
    while(x<=cnt)
        T[x]+=z,x+=x&-x;
}
C q(int x){
    C z;
    while(x)
        z+=T[x],x-=x&-x;
    return z;
}
priority_queue<array<int,4>,vector<array<int,4>>,greater<>>pq;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        pq.push({a,c,1,i});
        pq.push({b,d,0,i});
        mp[c],mp[d];
    }
    for(auto&[i,j]:mp)
        j=++cnt;
    upd(1,{0,1});
    while(pq.size()){
        auto[a,b,c,d]=pq.top();
        pq.pop();
        if(c)
            ans[d]=q(mp[b]),ans[d].x++;
        else
            upd(mp[b],ans[d]);
    }
    for(int i=0;i<n;i++)
        res+=ans[i];
    cout<<res.x<<' '<<res.y;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 4 ms 860 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1752 KB Output is correct
10 Correct 23 ms 3384 KB Output is correct
11 Correct 27 ms 4040 KB Output is correct
12 Correct 62 ms 7784 KB Output is correct
13 Correct 76 ms 9152 KB Output is correct
14 Correct 90 ms 12024 KB Output is correct
15 Correct 117 ms 11952 KB Output is correct
16 Correct 117 ms 13236 KB Output is correct
17 Correct 116 ms 13752 KB Output is correct
18 Correct 105 ms 14456 KB Output is correct
19 Correct 122 ms 14768 KB Output is correct
20 Correct 154 ms 15488 KB Output is correct