Submission #283698

# Submission time Handle Problem Language Result Execution time Memory
283698 2020-08-26T05:45:28 Z 최은수(#5746) 도로 건설 사업 (JOI13_construction) C++17
Compilation error
0 ms 0 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
const int mx=200010;
struct dsu
{
    int pa[mx];
    int par(int x)
    {
        if(pa[x]==0)
            return x;
        return pa[x]=par(pa[x]);
    }
    inline void uni(int x,int y)
    {
        x=par(x);
        y=par(y);
        if(x==y)
            return;
        pa[x]=y;
        return;
    }
}uf;
vector<pi>xyed;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,c;
    cin>>n>>m>>c;
    vector<pi>v(n);
    for(pi&t:v)
        cin>>t.fi>>t.se;
    vector<int>sv;
    for(int i=0;i<n;i++)
        sv.eb(i);
    sort(all(sv),[&](const int&x,const int&y){return v[x]<v[y];});
    for(int i=1;i<n;i++)
        if(v[sv[i]].fi==v[sv[i-1]].fi)
            xyed.eb(sv[i-1],sv[i]);
    sort(all(sv),[&](const int&x,const int&y){return pi(v[x].se,v[x].fi)<pi(v[y].se,v[y].fi);});
    for(int i=1;i<n;i++)
        if(v[sv[i]].se==v[sv[i-1]].se)
            xyed.eb(sv[i-1],sv[i]);
    vector<pair<pi,pi> >mv(m);
    for(auto&t:mv)
        cin>>t.fi.fi>>t.se.fi>>t.fi.se>>t.se.se;
    vector<pair<int,pi> >ev;
    vector<int>wv;
    for(pi&e:xyed)
    {
        bool f=1;
        for(auto&t:mv)
        {
            if(t.fi.fi<=v[e.se].fi&&v[e.fi].fi<=t.fi.se&&t.se.fi<=v[e.se].se&&v[e.fi].se<=t.se.se)
            {
                f=0;
                break;
            }
        }
        if(f)
            ev.eb(v[e.se].fi-v[e.fi].fi+v[e.se].se-v[e.fi].se,e);
    }
    sort(all(ev));
    for(auto&t:ev)
    {
        if(uf.par(t.se.fi)!=uf.par(t.se.se))
            wv.eb(t.fi);
        uf.uni(t.se.fi,t.se.se);
    }
    vector<ll>ps(1,0);
    for(int&t:wv)
        ps.eb(ps.back()+t);
    for(int i=0;i<c;i++)
    {
        int b,h;
        cin>>b>>h;
        if((int)wv.size()+h<n)
        {
            cout<<-1<<'\n';
            continue;
        }
        int pos=max(n-h,lower_bound(all(wv),b)-wv.begin());
        cout<<ps[pos]+(ll)(n-pos)*b<<'\n';
    }
    return 0;
}

Compilation message

construction.cpp: In function 'int main()':
construction.cpp:94:58: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   94 |         int pos=max(n-h,lower_bound(all(wv),b)-wv.begin());
      |                                                          ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from construction.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
construction.cpp:94:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   94 |         int pos=max(n-h,lower_bound(all(wv),b)-wv.begin());
      |                                                          ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from construction.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
construction.cpp:94:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   94 |         int pos=max(n-h,lower_bound(all(wv),b)-wv.begin());
      |                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from construction.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
construction.cpp:94:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   94 |         int pos=max(n-h,lower_bound(all(wv),b)-wv.begin());
      |                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from construction.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
construction.cpp:94:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   94 |         int pos=max(n-h,lower_bound(all(wv),b)-wv.begin());
      |                                                          ^