Submission #290937

#TimeUsernameProblemLanguageResultExecution timeMemory
290937TadijaSebezFun Tour (APIO20_fun)C++11
Compilation error
0 ms0 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define pii pair<int,int> int SUB(int root,int x){return attractionsBehind(root,x);} int DEP(int root,int x){return hoursRequired(root,x);} const int N=100050; int dep[N],sz[N]; int FindCentroid(int n){ pii mn={n,0}; sz[0]=n; for(int i=1;i<n;i++){ sz[i]=SUB(0,i); if(sz[i]*2>=n)mn=min(mn,{sz[i],i}); } return mn.second; } int type[N],dist[N]; vector<int> createFunTour(int n,int q){ int cen=FindCentroid(n); //printf("cen: %i\n",cen); vector<int> f; for(int i=0;i<n;i++){ dist[i]=DEP(cen,i); if(dist[i]==1&&sz[i]<sz[cen]){ f.pb(i); type[i]=f.size(); } } type[cen]=-1; for(int j=0;j<min(2,f.size());j++){ for(int i=0;i<n;i++)if(!type[i]){ if(SUB(i,f[j])==n-sz[f[j]]+1)type[i]=j+1; } } for(int i=0;i<n;i++)if(!type[i])type[i]=3; priority_queue<pii> pq[3]; for(int i=0;i<n;i++)if(type[i]>0)pq[type[i]-1].push({dist[i],i}); //for(int i=0;i<n;i++)printf("%i ",type[i]);printf("\n"); vector<int> ans; int ban=-1; //printf("%i %i %i\n",pq[0].size(),pq[1].size(),pq[2].size()); for(int i=1;i<3;i++)if(pq[i].size()>pq[0].size())swap(pq[i],pq[0]); pq[1].push({0,cen}); assert(pq[0].size()<=pq[1].size()+pq[2].size()); while(max({pq[0].size(),pq[1].size(),pq[2].size()})*2<pq[0].size()+pq[1].size()+pq[2].size()){ //printf("%i %i %i\n",pq[0].size(),pq[1].size(),pq[2].size()); int mx=0,sz=0,o=-1; for(int i=0;i<3;i++)if(i!=ban){ if(pq[i].size()){ int now=pq[i].top().first; if(now>mx||(now==mx&&sz<pq[i].size()))mx=now,sz=pq[i].size(),o=i; } } if(o==-1)break; ban=o; ans.pb(pq[o].top().second); pq[o].pop(); } for(int i=1;i<3;i++)if(pq[i].size()>pq[0].size())swap(pq[i],pq[0]); //assert(pq[0].size()==pq[1].size()+pq[2].size()); while(pq[0].size()){ ans.pb(pq[0].top().second); pq[0].pop(); if(pq[1].empty()||(pq[2].size()&&pq[2].top().first>pq[1].top().first))ans.pb(pq[2].top().second),pq[2].pop(); else ans.pb(pq[1].top().second),pq[1].pop(); } //ans.pb(cen); return ans; }

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:34:30: error: no matching function for call to 'min(int, std::vector<int>::size_type)'
   34 |  for(int j=0;j<min(2,f.size());j++){
      |                              ^
In file included from /usr/include/c++/9/vector:60,
                 from fun.h:1,
                 from fun.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> 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:
fun.cpp:34:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   34 |  for(int j=0;j<min(2,f.size());j++){
      |                              ^
In file included from /usr/include/c++/9/vector:60,
                 from fun.h:1,
                 from fun.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> 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:
fun.cpp:34:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   34 |  for(int j=0;j<min(2,f.size());j++){
      |                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from fun.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> _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:
fun.cpp:34:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |  for(int j=0;j<min(2,f.size());j++){
      |                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from fun.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> _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:
fun.cpp:34:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |  for(int j=0;j<min(2,f.size());j++){
      |                              ^
fun.cpp:55:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::priority_queue<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     if(now>mx||(now==mx&&sz<pq[i].size()))mx=now,sz=pq[i].size(),o=i;
      |                          ~~^~~~~~~~~~~~~