Submission #1069680

# Submission time Handle Problem Language Result Execution time Memory
1069680 2024-08-22T08:07:46 Z Faisal_Saqib Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vpl vector<pll>
const int N=5e5+10;
vpl ma[N];
ll paid[N],dist[N];
bool vis[N];
// ll dist_[2][N];
 
int max_score(int n, int x, int y, long long k, std::vector<int> U,std::vector<int> V, std::vector<int> W)
{
    for(int i=0;i<2*n;i++)
    {
        ma[i].clear();
        paid[i]=0;
        vis[i]=0;
        dist[i]=k+1;
    }
    int m=U.size();
    for(int i=0;i<m;i++)
    {
        ma[U[i]].push_back({W[i],V[i]});
        ma[U[i]+n].push_back({W[i],V[i]+n});
        ma[V[i]].push_back({W[i],U[i]});
        ma[V[i]+n].push_back({W[i],U[i]+n});
    }
    set<pll,vpl,greater<pll>> pq;
    pq.insert({0,x});
    pq.insert({0,y+n});
    dist[x]=0;
    dist[y+n]=0;
    ll cur=0;
    while(pq.size()>0)
    {
        pll it=*pq.begin();
        pq.erase(begin(pq));
 
 
        int u=it.second;
        ll c=it.first;
 
        if(vis[u])continue;


        if((cur+c)>k)
            continue;
        
 
        cur+=c;
        if(u<n)
        {
            paid[u+n]+=c;
            if(dist[u+n]!=(k+1) and !vis[u+n])
            {
                pq.erase({dist[u+n],u+n});
                dist[u+n]=max(0ll,(dist[u+n]-c));
                pq.insert({dist[u+n],u+n});
            }
        }
        else
        {
            paid[u-n]+=c;
            if(dist[u-n]!=(k+1) and !vis[u-n])
            {
                pq.erase({dist[u-n],u-n});
                dist[u-n]=max(0ll,(dist[u-n]-c));
                pq.insert({dist[u-n],u-n});
            }
        }
        vis[u]=1;
        for(auto [w,v]:ma[u])
        {
            ll cop=max(0ll,c+w-paid[v]);
            if(dist[v]>(cop))
            {
                dist[v]=cop;
                pq.insert({cop,v});
            }
        }
    }
    int total=0;
    for(int i=0;i<2*n;i++)
    {
        total+=vis[i];
    }
    return total;
}

Compilation message

In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_set.h: In instantiation of 'class std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >':
closing.cpp:30:31:   required from here
/usr/include/c++/10/bits/stl_set.h:111:65: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  111 |       static_assert(is_same<typename _Alloc::value_type, _Key>::value,
      |                                                                 ^~~~~
/usr/include/c++/10/bits/stl_set.h:129:22: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  129 |  rebind<_Key>::other _Key_alloc_type;
      |                      ^~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:132:40: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  132 |          key_compare, _Key_alloc_type> _Rep_type;
      |                                        ^~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:135:58: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  135 |       typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits;
      |                                                          ^~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:140:49: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  140 |       typedef typename _Alloc_traits::pointer   pointer;
      |                                                 ^~~~~~~
/usr/include/c++/10/bits/stl_set.h:141:54: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  141 |       typedef typename _Alloc_traits::const_pointer  const_pointer;
      |                                                      ^~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:142:51: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  142 |       typedef typename _Alloc_traits::reference   reference;
      |                                                   ^~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:143:56: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  143 |       typedef typename _Alloc_traits::const_reference  const_reference;
      |                                                        ^~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:147:51: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  147 |       typedef typename _Rep_type::const_iterator  iterator;
      |                                                   ^~~~~~~~
/usr/include/c++/10/bits/stl_set.h:148:51: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  148 |       typedef typename _Rep_type::const_iterator  const_iterator;
      |                                                   ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:149:58: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  149 |       typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
      |                                                          ^~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:150:58: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  150 |       typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
      |                                                          ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:151:47: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  151 |       typedef typename _Rep_type::size_type   size_type;
      |                                               ^~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:152:52: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  152 |       typedef typename _Rep_type::difference_type  difference_type;
      |                                                    ^~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:156:13: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  156 |       using node_type = typename _Rep_type::node_type;
      |             ^~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:157:13: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  157 |       using insert_return_type = typename _Rep_type::insert_return_type;
      |             ^~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:462:2: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  462 |  emplace(_Args&&... __args)
      |  ^~~~~~~
/usr/include/c++/10/bits/stl_set.h:509:7: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  509 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:518:7: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  518 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:755:14: error: using invalid field 'std::set<_Key, _Compare, _Alloc>::_M_t'
  755 |  -> decltype(_M_t._M_count_tr(__x))
      |              ^~~~
/usr/include/c++/10/bits/stl_set.h:840:23: error: using invalid field 'std::set<_Key, _Compare, _Alloc>::_M_t'
  840 |  -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
      |                       ^~~~
/usr/include/c++/10/bits/stl_set.h:846:29: error: using invalid field 'std::set<_Key, _Compare, _Alloc>::_M_t'
  846 |  -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
      |                             ^~~~
/usr/include/c++/10/bits/stl_set.h:870:23: error: using invalid field 'std::set<_Key, _Compare, _Alloc>::_M_t'
  870 |  -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
      |                       ^~~~
/usr/include/c++/10/bits/stl_set.h:876:23: error: using invalid field 'std::set<_Key, _Compare, _Alloc>::_M_t'
  876 |  -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
      |                       ^~~~
/usr/include/c++/10/bits/stl_set.h:898:7: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  898 |       equal_range(const key_type& __x)
      |       ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:902:7: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  902 |       equal_range(const key_type& __x) const
      |       ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:909:14: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  909 |  -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:909:39: error: using invalid field 'std::set<_Key, _Compare, _Alloc>::_M_t'
  909 |  -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
      |                                       ^~~~
/usr/include/c++/10/bits/stl_set.h:915:14: error: no type named 'value_type' in 'struct std::greater<std::pair<long long int, long long int> >'
  915 |  -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:915:39: error: using invalid field 'std::set<_Key, _Compare, _Alloc>::_M_t'
  915 |  -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
      |                                       ^~~~
closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:31:20: error: no matching function for call to 'std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::insert(<brace-enclosed initializer list>)'
   31 |     pq.insert({0,x});
      |                    ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_set.h:566:2: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<long long int, long long int>; _Compare = std::vector<std::pair<long long int, long long int> >; _Alloc = std::greater<std::pair<long long int, long long int> >]'
  566 |  insert(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_set.h:566:2: note:   template argument deduction/substitution failed:
closing.cpp:31:20: note:   candidate expects 2 arguments, 1 provided
   31 |     pq.insert({0,x});
      |                    ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_set.h:578:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<long long int, long long int>; _Compare = std::vector<std::pair<long long int, long long int> >; _Alloc = std::greater<std::pair<long long int, long long int> >]'
  578 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:578:43: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<long long int, long long int> >'
  578 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
closing.cpp:32:22: error: no matching function for call to 'std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::insert(<brace-enclosed initializer list>)'
   32 |     pq.insert({0,y+n});
      |                      ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_set.h:566:2: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<long long int, long long int>; _Compare = std::vector<std::pair<long long int, long long int> >; _Alloc = std::greater<std::pair<long long int, long long int> >]'
  566 |  insert(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_set.h:566:2: note:   template argument deduction/substitution failed:
closing.cpp:32:22: note:   candidate expects 2 arguments, 1 provided
   32 |     pq.insert({0,y+n});
      |                      ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_set.h:578:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<long long int, long long int>; _Compare = std::vector<std::pair<long long int, long long int> >; _Alloc = std::greater<std::pair<long long int, long long int> >]'
  578 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:578:43: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<long long int, long long int> >'
  578 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
closing.cpp:36:14: error: 'class std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' has no member named 'size'
   36 |     while(pq.size()>0)
      |              ^~~~
closing.cpp:38:20: error: 'class std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' has no member named 'begin'
   38 |         pll it=*pq.begin();
      |                    ^~~~~
closing.cpp:39:12: error: 'class std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' has no member named 'erase'
   39 |         pq.erase(begin(pq));
      |            ^~~~~
closing.cpp:39:26: error: no matching function for call to 'begin(std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >&)'
   39 |         pq.erase(begin(pq));
      |                          ^
In file included from /usr/include/c++/10/bits/range_access.h:36,
                 from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from closing.cpp:1:
/usr/include/c++/10/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   90 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/10/initializer_list:90:5: note:   template argument deduction/substitution failed:
closing.cpp:39:26: note:   'std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' is not derived from 'std::initializer_list<_Tp>'
   39 |         pq.erase(begin(pq));
      |                          ^
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from closing.cpp:1:
/usr/include/c++/10/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:51:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >]':
closing.cpp:39:26:   required from here
/usr/include/c++/10/bits/range_access.h:51:50: error: 'class std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' has no member named 'begin'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >]':
closing.cpp:39:26:   required from here
/usr/include/c++/10/bits/range_access.h:61:56: error: 'const class std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' has no member named 'begin'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   90 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note:   template argument deduction/substitution failed:
closing.cpp:39:26: note:   mismatched types '_Tp [_Nm]' and 'std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >'
   39 |         pq.erase(begin(pq));
      |                          ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:1:
/usr/include/c++/10/valarray:1214:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1214 |     begin(valarray<_Tp>& __va)
      |     ^~~~~
/usr/include/c++/10/valarray:1214:5: note:   template argument deduction/substitution failed:
closing.cpp:39:26: note:   'std::set<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >' is not derived from 'std::valarray<_Tp>'
   39 |         pq.erase(begin(pq));
      |                          ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
/usr/include/c++/10/valarray:1224:5: note:   template argument deduction/substitution failed:
closing.cpp:39:26: note:   'std::set<std::pair<long long int, long long int>, std::