답안 #378892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378892 2021-03-17T07:09:00 Z FatihSolak Plahte (COCI17_plahte) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define N 80005
#define M 1000000005
#define INF 2000000000000000005
using namespace std;
int dep[N];
int ans[N];
int par[N];
int pr[N];
set<int> col[N];
vector<int> de[N];
map<int,multiset<pair<long long,pair<long long,long long>>>> t;
struct Node{
    int a,b,c,d,pos;
    bool operator < (const Node other)const{
        if(a == other.a){
            return 1ll*(c-a)*(d-b) < 1ll*(other.c-other.a)*(other.d-other.b);
        }
        return a < other.a;
    }
};
void upd(int v,int tl,int tr,int l,int r,long long val1,long long val2,long long val3,int ok){
    if(tr < l || r < tl){
        return;
    }
    if(l <= tl && tr <= r){
        if(ok){
            assert(t[v].count({val1,{val2,val3}}));
            t[v].erase(t[v].find({val1,{val2,val3}}));
        }
        else{
            t[v].insert({val1,{val2,val3}});
        }
        return;
    }
    int tm = (tl+tr)/2;
    upd(v*2,tl,tm,l,r,val1,val2,val3,ok);
    upd(v*2+1,tm+1,tr,l,r,val1,val2,val3,ok);
}
pair<long long,pair<long long,long long>> get(int v,int l,int r,int pos){
    int m = (l+r)/2;
    if(l == r){
        if(t[v].empty()){
            return make_pair(INF,make_pair(INF,INF));
        }
        return *t[v].begin();
    }
    if(pos<=m){
        if(t[v].empty()){
            return min(make_pair(INF,make_pair(INF,INF)),get(v*2,l,m,pos));
        }
        return min(*t[v].begin(),get(v*2,l,m,pos));
    }
    else{
        if(t[v].empty()){
            return min(make_pair(INF,make_pair(INF,INF)),get(v*2+1,m+1,r,pos));
        }
        return min(*t[v].begin(),get(v*2+1,m+1,r,pos));
    }
}
void go_par(int v){
    ans[v] = col[pr[v]].size();
    if(par[v] == -1){
        return;
    }
    if(col[pr[v]].size() > col[pr[par[v]]].size()){
        for(auto u:col[pr[par[v]]]){
            col[pr[v]].insert(u);
        }
        pr[par[v]] = pr[v];
    }
    else{
        for(auto u:col[pr[v]]){
            col[pr[par[v]]].insert(u);
        }
    }
}
void solve(){
    int n,m;
    cin >> n >> m;
    vector<Node> v;
    for(int i = 0;i<n;i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        v.push_back({a,b,c,d,i});
    }
    sort(v.begin(),v.end());
    set<pair<int,Node>> s;
    for(auto u:v){
        while(s.size() && s.begin()->first < u.a){
            auto k = s.begin()->second;
            s.erase(s.begin());
            upd(1,1,M,k.b,k.d,1ll*(k.c-k.a)*(k.d-k.b) ,dep[k.pos],k.pos,1);
        }
        auto k = get(1,1,M,u.b);
        if(k.first == INF){
            par[u.pos] = -1;
        }
        else{
            dep[u.pos] = dep[k.second.second] - 1;
            par[u.pos] = k.second.second;
        }
        s.insert({u.c,u});
        upd(1,1,M,u.b,u.d,1ll*(u.c-u.a)*(u.d-u.b) ,dep[u.pos],u.pos,0);
    }
    /*
    for(int i=0;i<n;i++){
        cout << par[i] << endl;
    }*/
    vector<pair<int,pair<int,int>>> v2;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin >> a >> b >> c;
        v2.push_back({a,{b,c}});
    }
    sort(v2.begin(),v2.end());
    t.clear();
    s.clear();
    int cnt = 0;
    for(auto u:v2){
        while(cnt != n && v[cnt].a <= u.first){
            auto k = v[cnt];
            upd(1,1,M,k.b,k.d,1ll*(k.c-k.a)*(k.d-k.b) ,dep[k.pos],k.pos,0);
            s.insert({k.c,k});
            cnt++;
        }
        while(s.size() && s.begin()->first < u.first){
            auto k = s.begin()->second;
            s.erase(s.begin());
            upd(1,1,M,k.b,k.d,1ll*(k.c-k.a)*(k.d-k.b) ,dep[k.pos],k.pos,1);
        }
        auto k = get(1,1,M,u.second.first);
        if(k.first == INF){
            continue;
        }
        else{
            col[k.second.second].insert(u.second.second);
        }
    }
    /*
    for(int i=0;i<n;i++){
        for(auto u:col[i])cout << u << " ";
        cout << endl;
    }*/
    for(int i=0;i<n;i++){
        dep[i] = -1*dep[i];
        pr[i] = i;
        de[dep[i]].push_back(i);
    }
    for(int i=n-1;i>=0;i--){
        for(auto u:de[i]){
            go_par(u);
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Compilation message

plahte.cpp: In function 'std::pair<long long int, std::pair<long long int, long long int> > get(int, int, int, int)':
plahte.cpp:50:74: error: no matching function for call to 'min(std::pair<long int, std::pair<long int, long int> >, std::pair<long long int, std::pair<long long int, long long int> >)'
   50 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2,l,m,pos));
      |                                                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
plahte.cpp:50:74: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<long int, std::pair<long int, long int> >' and 'std::pair<long long int, std::pair<long long int, long long int> >')
   50 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2,l,m,pos));
      |                                                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
plahte.cpp:50:74: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<long int, std::pair<long int, long int> >' and 'std::pair<long long int, std::pair<long long int, long long int> >')
   50 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2,l,m,pos));
      |                                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
plahte.cpp:50:74: note:   'std::pair<long int, std::pair<long int, long int> >' is not derived from 'std::initializer_list<_Tp>'
   50 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2,l,m,pos));
      |                                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
plahte.cpp:50:74: note:   'std::pair<long int, std::pair<long int, long int> >' is not derived from 'std::initializer_list<_Tp>'
   50 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2,l,m,pos));
      |                                                                          ^
plahte.cpp:56:78: error: no matching function for call to 'min(std::pair<long int, std::pair<long int, long int> >, std::pair<long long int, std::pair<long long int, long long int> >)'
   56 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2+1,m+1,r,pos));
      |                                                                              ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
plahte.cpp:56:78: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<long int, std::pair<long int, long int> >' and 'std::pair<long long int, std::pair<long long int, long long int> >')
   56 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2+1,m+1,r,pos));
      |                                                                              ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
plahte.cpp:56:78: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<long int, std::pair<long int, long int> >' and 'std::pair<long long int, std::pair<long long int, long long int> >')
   56 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2+1,m+1,r,pos));
      |                                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
plahte.cpp:56:78: note:   'std::pair<long int, std::pair<long int, long int> >' is not derived from 'std::initializer_list<_Tp>'
   56 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2+1,m+1,r,pos));
      |                                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from plahte.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
plahte.cpp:56:78: note:   'std::pair<long int, std::pair<long int, long int> >' is not derived from 'std::initializer_list<_Tp>'
   56 |             return min(make_pair(INF,make_pair(INF,INF)),get(v*2+1,m+1,r,pos));
      |                                                                              ^