Submission #669193

#TimeUsernameProblemLanguageResultExecution timeMemory
669193alvingogoScales (IOI15_scales)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "scales.h" #pragma GCC optimize("Ofast") #define AquA cin.tie(0);ios_base::sync_with_stdio(0); #define fs first #define sc second #define p_q priority_queue using namespace std; map<vector<int>,vector<int>(4)> mp; int po[7]={1,3,9,27,81,243,729}; vector<vector<int> > z; int get(vector<int> g,int a,int b,int c,int t){ if(t==-1){ for(int i=0;i<6;i++){ if(g[i]==a || g[i]==b || g[i]==c){ return g[i]; } } } else if(t==-3){ for(int i=5;i>=0;i--){ if(g[i]==a || g[i]==b || g[i]==c){ return g[i]; } } } else if(t==-2){ int cnt=0; for(int i=0;i<6;i++){ if(g[i]==a || g[i]==b || g[i]==c){ cnt++; } if(cnt==2){ return g[i]; } } } else{ int cnt=0; for(int i=0;i<6;i++){ if(g[i]==t){ cnt++; } if(cnt && (g[i]==a || g[i]==b || g[i]==c)){ return g[i]; } } return get(g,a,b,c,1,-1); } } int fg(int a,int b,int c){ return getHeaviest(a+1,b+1,c+1)-1; } int fm(int a,int b,int c){ return getMedian(a+1,b+1,c+1)-1; } int fl(int a,int b,int c){ return getLightest(a+1,b+1,c+1)-1; } int nx(int a,int b,int c,int d){ return getNextLightest(a+1,b+1,c+1,d+1)-1; } int cal(vector<int>& x,int t,int i,int j,int k){ vector<int> b,c,d; for(auto y:x){ auto h=z[x]; int a=get(h,i,j,k,t); if(a==i){ b.push_back(h); } else if(a==j){ c.push_back(h); } else{ d.push_back(h); } } if(dfs(b,s-1) && dfs(c,s-1) && dfs(d,s-1)){ return 1; } return 0; } int dfs(vector<int>& x,int s){ if(x.size()>po[s]){ return 1; } else if(mp.find(x)!=mp.end()){ if(mp[x][0]==-1){ return 0; } else{ return 1; } } for(int i=0;i<4;i++){ for(int j=i+1;j<5;j++){ for(int k=j+1;k<6;k++){ for(int t=-3;t<6;t++){ if(t!=i && t!=j && t!=k){ if(cal(x,t,i,j,k)){ return mp[x]={i,j,k,t}; } } } } } } return mp[x]={-1,-1,-1,-1}; } void init(int T){ vector<int> g(n); iota(g.begin(),g.end(),0); for(int i=0;i<720;i++){ z.push_back(g); next_permutation(g.begin(),g.end()); } vector<int> k(720); iota(k.begin(),k.end(),0); dfs(k,6); } void orderCoins(){ vector<int> g(720); iota(g.begin(),g.end(),0); while(g.size()>1){ auto h=mp[g]; vector<int> nw; int y; if(h[3]==-1){ y=fl(h[0],h[1],h[2]); } else if(h[3]==-2){ y=fm(h[0],h[1],h[2]); } else if(h[3]==-3){ y=fg(h[0],h[1],h[2]); } else{ y=nx(h[0],h[1],h[2],h[3]); } for(auto r:g){ if(get(z[r],h[0],h[1],h[2],h[3])==y){ nw.push_back(r); } } g=nw; } answer(g); }

Compilation message (stderr)

scales.cpp:10:17: error: temporary of non-literal type 'std::vector<int>' in a constant expression
   10 | map<vector<int>,vector<int>(4)> mp;
      |                 ^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from scales.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector<int>' is not literal because:
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector<int>' has a non-trivial destructor
scales.cpp:10:31: error: type/value mismatch at argument 2 in template parameter list for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
   10 | map<vector<int>,vector<int>(4)> mp;
      |                               ^
scales.cpp:10:31: note:   expected a type, got 'std::vector<int>(4, std::allocator<int>())'
scales.cpp:10:31: error: template argument 4 is invalid
scales.cpp: In function 'int get(std::vector<int>, int, int, int, int)':
scales.cpp:49:32: error: no matching function for call to 'get(std::vector<int>&, int&, int&, int&, int, int)'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
scales.cpp:13:5: note: candidate: 'int get(std::vector<int>, int, int, int, int)'
   13 | int get(vector<int> g,int a,int b,int c,int t){
      |     ^~~
scales.cpp:13:5: note:   candidate expects 5 arguments, 6 provided
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)'
  223 |     get(std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:223:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::pair<_Tp1, _Tp2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)'
  228 |     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:228:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::pair<_Tp1, _Tp2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)'
  233 |     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:233:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::pair<_Tp1, _Tp2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)'
  238 |     get(const std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:238:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::pair<_Tp1, _Tp2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)'
  247 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:247:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::pair<_T1, _T2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)'
  252 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:252:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::pair<_T1, _T2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)'
  257 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:257:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::pair<_T1, _T2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)'
  262 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:262:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::pair<_T1, _T2>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)'
  267 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:267:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::pair<_Up, _Tp>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)'
  272 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:272:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::pair<_Up, _Tp>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)'
  277 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:277:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::pair<_Up, _Tp>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from scales.cpp:1:
/usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)'
  282 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:282:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::pair<_Up, _Tp>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)'
  334 |     get(array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:334:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::array<_Tp, _Nm>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)'
  343 |     get(array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:343:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::array<_Tp, _Nm>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)'
  351 |     get(const array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:351:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::array<_Tp, _Nm>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)'
  360 |     get(const array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:360:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::array<_Tp, _Nm>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&)'
 1294 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1294:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const std::tuple<_Elements ...>&)'
 1300 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1300:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&)'
 1306 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1306:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const std::tuple<_Elements ...>&&)'
 1315 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1315:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_Elements ...>&)'
 1338 |     get(tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1338:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_Elements ...>&&)'
 1344 |     get(tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1344:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_Elements ...>&)'
 1350 |     get(const tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1350:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from scales.cpp:1:
/usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_Elements ...>&&)'
 1357 |     get(const tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1357:5: note:   template argument deduction/substitution failed:
scales.cpp:49:32: note:   'std::vector<int>' is not derived from 'const std::tuple<_Elements ...>'
   49 |         return get(g,a,b,c,1,-1);
      |                                ^
scales.cpp: In function 'int cal(std::vector<int>&, int, int, int, int)':
scales.cpp:67:17: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >'