답안 #1029009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029009 2024-07-20T11:15:45 Z lucri 사다리꼴 (balkan11_trapezoid) C++17
46 / 100
153 ms 20852 KB
#include <bits/stdc++.h>
#define MOD 30013
using namespace std;
struct arboreintervale{int nrmax,fr;}aint[800010],val[100010],pre;
priority_queue<pair<int,pair<int,int>>>q;
int n,a[100010],b[100010],c[100010],d[100010],e[200010];
arboreintervale join(arboreintervale a,arboreintervale b)
{
    if(a.nrmax>b.nrmax)
        return a;
    if(a.nrmax<b.nrmax)
        return b;
    return {a.nrmax,a.fr+b.fr};
}
void adauga(int poz,int b,int e,int pozu,arboreintervale val)
{
    if(pozu>e||pozu<b)
        return;
    if(b==e)
    {
        aint[poz]=val;
        return;
    }
    adauga(poz*2,b,(b+e)/2,pozu,val);
    adauga(poz*2+1,(b+e)/2+1,e,pozu,val);
    aint[poz]=join(aint[poz*2],aint[poz*2+1]);
}
void maxim(int poz,int b,int e,int bi,int ei)
{
    if(bi>e||ei<b)
        return;
    if(bi<=b&&e<=ei)
    {
        pre=join(pre,aint[poz]);
        return;
    }
    maxim(poz*2,b,(b+e)/2,bi,ei);
    maxim(poz*2+1,(b+e)/2+1,e,bi,ei);
}
unordered_map<int,int>cod;
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        e[2*i-1]=c[i];
        e[2*i]=d[i];
    }
    std::sort(e+1,e+2*n+1);
    for(int i=1;i<=2*n;++i)
        cod[e[i]]=i;
    for(int i=1;i<=n;++i)
    {
        c[i]=cod[c[i]];
        d[i]=cod[d[i]];
        q.push({-a[i],{c[i],i}});
        q.push({-b[i],{d[i],-i}});
    }
    while(!q.empty())
    {
        pre={0,1};
        int a=-q.top().first,b=q.top().second.first,c=q.top().second.second;
        q.pop();
        if(c<0)
            adauga(1,1,2*n,b,val[-c]);
        else
        {
            maxim(1,1,2*n,1,b);
            ++pre.nrmax;
            val[c]=pre;
        }
    }
    cout<<aint[1].nrmax<<' '<<aint[1].fr;
    return 0;
}

Compilation message

trapezoid.cpp: In function 'int main()':
trapezoid.cpp:63:13: warning: unused variable 'a' [-Wunused-variable]
   63 |         int a=-q.top().first,b=q.top().second.first,c=q.top().second.second;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Partially correct 1 ms 4444 KB Partially correct
4 Partially correct 2 ms 4444 KB Partially correct
5 Partially correct 4 ms 4700 KB Partially correct
6 Partially correct 5 ms 5016 KB Partially correct
7 Partially correct 6 ms 4956 KB Partially correct
8 Partially correct 7 ms 5096 KB Partially correct
9 Partially correct 18 ms 5916 KB Partially correct
10 Partially correct 28 ms 7156 KB Partially correct
11 Partially correct 36 ms 7904 KB Partially correct
12 Partially correct 77 ms 12992 KB Partially correct
13 Partially correct 106 ms 12736 KB Partially correct
14 Partially correct 110 ms 15548 KB Partially correct
15 Partially correct 120 ms 17332 KB Partially correct
16 Partially correct 125 ms 16592 KB Partially correct
17 Partially correct 137 ms 18868 KB Partially correct
18 Partially correct 125 ms 19564 KB Partially correct
19 Partially correct 151 ms 19560 KB Partially correct
20 Partially correct 153 ms 20852 KB Partially correct