Submission #1106593

#TimeUsernameProblemLanguageResultExecution timeMemory
1106593salmonFun Tour (APIO20_fun)C++14
Compilation error
0 ms0 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; vector<int> createFunTour(int N, int Q){ int lst[N + 1]; int d[N + 1]; int d1[N + 2][2]; set<pair<int,int>,greater<pair<int,int>>> sat[3]; for(int i = 0; i < N; i++){ lst[i] = attractionsBehind(0,i); } pair<int,int> ii = {N + 90,-1}; for(int i = 0; i < N; i++){ if(lst[i] >= (N+1)/2 ) ii = min(ii,{lst[i],i}); } int it = ii.second; for(int i = 0; i < N; i++){ d[i] = hoursRequired(it,i); } vector<int> tee; for(int i = 0; i < N; i++){ if(d[i] == 1) tee.push_back(i); } if(tee.size() == 1){ return {0,1}; } else{ for(int i = 0; i < N; i++){ d1[i][0] = hoursRequired(i,tee[0]); d1[i][1] = hoursRequired(i,tee[1]); } for(int i = 0; i < N; i++){ if(i == it) continue; if(d1[i][0] < d[i]){ sat[0].insert({d[i],i}); } else if(d1[i][1] < d[i]){ sat[1].insert({d[i],i}); } else sat[2].insert({d[i],i}); } int prev = -1; vector<int> ans = {}; N = 2; sat[0] = {1}; sat[1] = {2}; sat[2]; while(max(max(sat[0].size(),sat[1].size() ), sat[2].size()) < (N/2) ){ assert (!(sat[0].empty()) && !(sat[1].empty()) && !(sat[2].empty())); if(prev == -1){ pair<int,int> ii = {-10,-1}; for(int i = 0; i < 3; i++) ii = max(ii, {sat[i].begin() -> first,i}); prev = ii.second; ans.push_back(sat[prev].begin() -> second); sat[prev].erase(sat[prev].begin()); N--; } else{ pair<int,int> ii = {-10,-1}; for(int i = 0; i < 3; i++) if(i != prev) ii = max(ii, {sat[i].begin() -> first,i}); prev = ii.second; ans.push_back(sat[prev].begin() -> second); sat[prev].erase(sat[prev].begin()); N--; } } pair<int,int> ii = {-10,-1}; for(int i = 0; i < 3; i++) ii = max(ii, {sat[i].size(),i}); int fat = ii.second; while(sat[0].size() + sat[1].size() + sat[2].size() > 0){ if(prev != fat){ prev = fat; ans.push_back(sat[prev].begin() -> second); sat[prev].erase(sat[prev].begin()); N--; } else{ ii = {-10,-1}; for(int i = 0; i < 3; i++) if(i != prev && !sat[i].empty())ii = max(ii, {sat[i].begin() -> first,i}); prev = ii.second; ans.push_back(sat[prev].begin() -> second); sat[prev].erase(sat[prev].begin()); N--; } } ans.push_back(it); return ans; } }

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:57:20: error: no match for 'operator=' (operand types are 'std::set<std::pair<int, int>, std::greater<std::pair<int, int> > >' and '<brace-enclosed initializer list>')
   57 |         sat[0] = {1};
      |                    ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from fun.cpp:2:
/usr/include/c++/10/bits/stl_set.h:298:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(const std::set<_Key, _Compare, _Alloc>&) [with _Key = std::pair<int, int>; _Compare = std::greater<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  298 |       operator=(const set&) = default;
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_set.h:298:17: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::set<std::pair<int, int>, std::greater<std::pair<int, int> > >&'
  298 |       operator=(const set&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:302:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::set<_Key, _Compare, _Alloc>&&) [with _Key = std::pair<int, int>; _Compare = std::greater<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  302 |       operator=(set&&) = default;
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_set.h:302:17: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int>, std::greater<std::pair<int, int> > >&&'
  302 |       operator=(set&&) = default;
      |                 ^~~~~
/usr/include/c++/10/bits/stl_set.h:316:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Key = std::pair<int, int>; _Compare = std::greater<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  316 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_set.h:316:46: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >'
  316 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
fun.cpp:58:20: error: no match for 'operator=' (operand types are 'std::set<std::pair<int, int>, std::greater<std::pair<int, int> > >' and '<brace-enclosed initializer list>')
   58 |         sat[1] = {2};
      |                    ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from fun.cpp:2:
/usr/include/c++/10/bits/stl_set.h:298:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(const std::set<_Key, _Compare, _Alloc>&) [with _Key = std::pair<int, int>; _Compare = std::greater<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  298 |       operator=(const set&) = default;
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_set.h:298:17: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::set<std::pair<int, int>, std::greater<std::pair<int, int> > >&'
  298 |       operator=(const set&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:302:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::set<_Key, _Compare, _Alloc>&&) [with _Key = std::pair<int, int>; _Compare = std::greater<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  302 |       operator=(set&&) = default;
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_set.h:302:17: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int>, std::greater<std::pair<int, int> > >&&'
  302 |       operator=(set&&) = default;
      |                 ^~~~~
/usr/include/c++/10/bits/stl_set.h:316:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Key = std::pair<int, int>; _Compare = std::greater<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  316 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_set.h:316:46: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >'
  316 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
fun.cpp:59:14: warning: statement has no effect [-Wunused-value]
   59 |         sat[2];
      |         ~~~~~^
fun.cpp:61:69: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   61 |         while(max(max(sat[0].size(),sat[1].size() ), sat[2].size()) < (N/2) ){
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~