Submission #994534

#TimeUsernameProblemLanguageResultExecution timeMemory
994534aaaaaarrozClosing Time (IOI23_closing)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<pair<ll,ll>>>graph; vector<bool> vis; void dfs1(vector<ll> &dist, ll x, ll d){ vis[x] = true; dist[x] = d; for (auto [y, w] : graph[x]){ if (!vis[y]){ dfs1(dist, y, d + w); } } } void dfs2(vector<pair<ll,ll>>dist, ll x, ll d){ vis[x] = true; dist[x].first= d; for (auto [y, w] : graph[x]){ if (!vis[y]){ dfs2(dist, y, d + w); } } } ll max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W){ graph.assign(N,vector<pair<ll,ll>>()); for(ll i=0;i<(N-1);i++){ graph[U[i]].push_back({V[i],W[i]}); graph[V[i]].push_back({U[i],W[i]}); } vis.assign(N,false); vector<ll>distX(N); dfs1(distX,X,0); vis.assign(N,false); vector<ll>distY(N); dfs1(distY,Y,0); vis.assign(N,false); vector<pair<ll,ll>>orden(N); for(ll i=0;i<N;i++){ pair<ll,ll>par; par.first=0; par.second=i; orden[i]=par; } dfs2(orden,max_element(distX.begin(),distX.end())-distX.begin(),0); sort(orden.begin(),orden.end()); ll pos_x; ll pos_y; for(ll i=0;i<N;i++){ if(orden[i].second==X){ pos_x=i; } else if(orden[i].second==Y){ pos_y=i; } } int ans=0; for(ll i=0;i<=pos_x;i++){ for(ll j=pos_x;j<N;j++){ for(ll k=0;k<=pos_y;k++){ for(ll l=pos_y;l<N;l++){ ll suma=0; for(ll index=0;i<N;index++){ ll v=0; if(index>=i&&index<=j){ v=max(v,distX[orden[index].second]); } else if(index>=k&&index<=l){ v=max(v,distY[orden[index].second]); } suma+=v; } if(suma<=K){ ans=max(j-i+1+k-l+1,ans); } } } } } return ans; }

Compilation message (stderr)

closing.cpp: In function 'll max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:73:30: error: no matching function for call to 'max(ll, int&)'
   73 |       ans=max(j-i+1+k-l+1,ans);
      |                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
closing.cpp:73:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   73 |       ans=max(j-i+1+k-l+1,ans);
      |                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
closing.cpp:73:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   73 |       ans=max(j-i+1+k-l+1,ans);
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
closing.cpp:73:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   73 |       ans=max(j-i+1+k-l+1,ans);
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
closing.cpp:73:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   73 |       ans=max(j-i+1+k-l+1,ans);
      |                              ^