Submission #444020

#TimeUsernameProblemLanguageResultExecution timeMemory
444020yungyaoThe Collection Game (BOI21_swaps)C++17
Compilation error
0 ms0 KiB
using namespace std; #include <iostream> #include <algorithm> #include <queue> #include <stack> #include <map> #include <set> #include <utility> #include <vector> #include <memory.h> typedef long long LL; typedef pair<int,int> pii; #define F first #define S second #define mkp make_pair #define iter(x) x.begin(),x.end() #define MEM(s,e) memset(s,e,sizeof(s)) const int maxn = 0; #include <swaps.h> bool ask(int u,int v){ schedule(i,v); vector <int> v = visit(); return v[0]; } void mergesort(vector <int> v){ if (v.size() == 1) return v; else if (v.size() == 2){ if (ask(v[0],v[1])) return v; else return {v[1],v[0]}; } vector <int> l,r; for (int i=0;i<v.size();++i){ if (i < v.size() / 2) l.push_back(v[i]); else r.push_back(v[i]); } l = mergesort(l); r = mergesort(r); v.clear(); for (int i=0,j=0;i<l.size() or j<r.size();){ if (i<l.size() and j<r.size()){ if (ask(l[i],r[j])) v.push_back(l[i++]); else v.push_back(r[j++]); } else if (i < l.size()) v.push_back(l[i++]); else v.push_back(r[j++]); } return v; } void solve(int n,int v){ vector <int> arr(n); for (int i=0;i<n;++i) arr[i] = i + 1; arr = mergesort(arr); answer(arr); }

Compilation message (stderr)

swaps.cpp: In function 'bool ask(int, int)':
swaps.cpp:24:14: error: 'i' was not declared in this scope
   24 |     schedule(i,v);
      |              ^
swaps.cpp:25:18: error: declaration of 'std::vector<int> v' shadows a parameter
   25 |     vector <int> v = visit();
      |                  ^
swaps.cpp:23:20: note: 'int v' previously declared here
   23 | bool ask(int u,int v){
      |                ~~~~^
swaps.cpp: In function 'void mergesort(std::vector<int>)':
swaps.cpp:30:31: error: return-statement with a value, in function returning 'void' [-fpermissive]
   30 |     if (v.size() == 1) return v;
      |                               ^
swaps.cpp:32:36: error: return-statement with a value, in function returning 'void' [-fpermissive]
   32 |         if (ask(v[0],v[1])) return v;
      |                                    ^
swaps.cpp:33:31: error: return-statement with a value, in function returning 'void' [-fpermissive]
   33 |         else return {v[1],v[0]};
      |                               ^
swaps.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i=0;i<v.size();++i){
      |                  ~^~~~~~~~~
swaps.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (i < v.size() / 2) l.push_back(v[i]);
      |             ~~^~~~~~~~~~~~~~
swaps.cpp:42:20: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   42 |     l = mergesort(l); r = mergesort(r);
      |                    ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from swaps.cpp:3:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'void' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from swaps.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'void' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'void' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
swaps.cpp:42:38: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   42 |     l = mergesort(l); r = mergesort(r);
      |                                      ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from swaps.cpp:3:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'void' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from swaps.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'void' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'void' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
swaps.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i=0,j=0;i<l.size() or j<r.size();){
      |                      ~^~~~~~~~~
swaps.cpp:44:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i=0,j=0;i<l.size() or j<r.size();){
      |                                    ~^~~~~~~~~
swaps.cpp:45:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (i<l.size() and j<r.size()){
      |             ~^~~~~~~~~
swaps.cpp:45:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (i<l.size() and j<r.size()){
      |                            ~^~~~~~~~~
swaps.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         else if (i < l.size()) v.push_back(l[i++]);
      |                  ~~^~~~~~~~~~
swaps.cpp:52:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   52 |     return v;
      |            ^
swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:58:24: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   58 |     arr = mergesort(arr);
      |                        ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from swaps.cpp:3:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'void' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from swaps.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'void' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'void' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~