제출 #571221

#제출 시각아이디문제언어결과실행 시간메모리
571221Deepesson로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "robots.h" typedef std::pair<int,int> pii; typedef std::pair<int,int*> pipo; int putaway(int A,int B,int T,int _X[],int _Y[],int _W[],int _S[]){ std::vector<int> X,Y,W,S; for(int i=0;i!=A;++i){ X.push_back(_X[i]); } for(int i=0;i!=B;++i){ Y.push_back(_Y[i]); } for(int i=0;i!=T;++i){ W.push_back(_W[i]); S.push_back(_S[i]); } { std::vector<pipo> vec; for(auto&x:X){ vec.push_back({x,&x}); } for(auto&x:Y){ vec.push_back({x,&x}); } for(auto&x:W){ vec.push_back({x,&x}); } for(auto&x:S){ vec.push_back({x,&x}); } std::sort(vec.begin(),vec.end()); int cur=2,last=-1; for(auto&x:vec){ if(x.first!=last){ ++cur; last=x.first; } *x.second=cur; } } std::sort(X,&X[A]); std::sort(Y,&Y[B]); int pesos[T]={}; { std::vector<pii> vec; ///T itens for(int i=0;i!=T;++i){ vec.push_back({W[i],i}); } std::sort(vec.begin(),vec.end()); ///A robos int soma[T]={}; int cur=0; for(int i=0;i!=A;++i){ while(cur!=T&&(vec[cur].first<X[i])){ ++cur; } if(cur){ soma[cur-1]++; } } int s=0; for(int i=T-1;i!=-1;--i){ s+=soma[i]; pesos[vec[i].second]+=s; } } { std::vector<pii> vec; ///T itens for(int i=0;i!=T;++i){ vec.push_back({S[i],i}); } std::sort(vec.begin(),vec.end()); ///A robos int soma[T]={}; int cur=0; for(int i=0;i!=B;++i){ while(cur!=T&&(vec[cur].first<Y[i])){ ++cur; } if(cur){ soma[cur-1]++; } } int s=0; for(int i=T-1;i!=-1;--i){ s+=soma[i]; pesos[vec[i].second]+=s; } } for(auto&x:pesos)if(!x)return -1; int l=0,r=T; while(l<r){ int m = (l+r)/2; int retirou=0; bool pegou[T]={}; { for(int i=0;i!=A;++i){ int pos=-1,valor = 1e9; for(int j=0;j!=T;++j){ if(pegou[j])continue; if(W[j]<X[i]){ if(pesos[j]<valor){ valor=pesos[j]; pos=j; } } } if(pos!=-1){ pegou[pos]=true; ++retirou; } } for(int i=0;i!=B;++i){ int pos=-1,valor=1e9; for(int j=0;j!=T;++j){ if(pegou[j])continue; if(S[j]<Y[i]){ if(pesos[j]<valor){ valor=pesos[j]; pos=j; } } } if(pos!=-1){ pegou[pos]=true; ++retirou; } } if(retirou==T){ break; } } if(retirou==T){ r=m; }else l=m+1; } return l; }

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:41:22: error: no matching function for call to 'sort(std::vector<int>&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type*)'
   41 |     std::sort(X,&X[A]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4849:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4849 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:4849:5: note:   template argument deduction/substitution failed:
robots.cpp:41:22: note:   deduced conflicting types for parameter '_RAIter' ('std::vector<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type*' {aka 'int*'})
   41 |     std::sort(X,&X[A]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:4880:5: note:   template argument deduction/substitution failed:
robots.cpp:41:22: note:   deduced conflicting types for parameter '_RAIter' ('std::vector<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type*' {aka 'int*'})
   41 |     std::sort(X,&X[A]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:292:1: note:   template argument deduction/substitution failed:
robots.cpp:41:22: note:   candidate expects 4 arguments, 2 provided
   41 |     std::sort(X,&X[A]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
robots.cpp:41:22: note:   candidate expects 3 arguments, 2 provided
   41 |     std::sort(X,&X[A]);
      |                      ^
robots.cpp:42:22: error: no matching function for call to 'sort(std::vector<int>&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type*)'
   42 |     std::sort(Y,&Y[B]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4849:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4849 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:4849:5: note:   template argument deduction/substitution failed:
robots.cpp:42:22: note:   deduced conflicting types for parameter '_RAIter' ('std::vector<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type*' {aka 'int*'})
   42 |     std::sort(Y,&Y[B]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:4880:5: note:   template argument deduction/substitution failed:
robots.cpp:42:22: note:   deduced conflicting types for parameter '_RAIter' ('std::vector<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type*' {aka 'int*'})
   42 |     std::sort(Y,&Y[B]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:292:1: note:   template argument deduction/substitution failed:
robots.cpp:42:22: note:   candidate expects 4 arguments, 2 provided
   42 |     std::sort(Y,&Y[B]);
      |                      ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
robots.cpp:42:22: note:   candidate expects 3 arguments, 2 provided
   42 |     std::sort(Y,&Y[B]);
      |                      ^