# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527261 | 2022-02-17T04:33:49 Z | Hydroxic_Acid | On the Grid (FXCUP4_grid) | C++17 | Compilation error |
0 ms | 0 KB |
#include "grid.h" #include <vector> using namespace std; vector<int> SortDisks(int N) { vector<int> v; int last = N - 1; for(int i = 0; i < N; i++) v.push_back(i); int X = PutDisks(v); while(X > N){ int cnt = 0; while(X < last + N){ int temp = vector[cnt]; vector[cnt] = vector[last]; vector[last] = temp; cnt++ } last--; } return v; }
Compilation message
grid.cpp: In function 'std::vector<int> SortDisks(int)': grid.cpp:13:21: error: missing template arguments before '[' token 13 | int temp = vector[cnt]; | ^ grid.cpp:14:24: error: missing template arguments before '[' token 14 | vector[cnt] = vector[last]; | ^ grid.cpp:15:19: error: class template argument deduction failed: 15 | vector[last] = temp; | ^~~~ grid.cpp:15:19: error: no matching function for call to 'vector(int&)' In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:1876:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> std::vector<_ValT, _Allocator>' 1876 | vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:1876:5: note: template argument deduction/substitution failed: grid.cpp:15:19: note: candidate expects 3 arguments, 1 provided 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:389:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>' 389 | class vector : protected _Vector_base<_Tp, _Alloc> | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:389:11: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>' 487 | vector() = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:487:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: candidate expects 0 arguments, 1 provided 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&)-> std::vector<_Tp, _Alloc>' 522 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:522:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: candidate expects 3 arguments, 1 provided 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>' 553 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:553:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>' 572 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:572:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, const allocator_type&)-> std::vector<_Tp, _Alloc>' 575 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:575:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type)-> std::vector<_Tp, _Alloc>' 585 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:585:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type)-> std::vector<_Tp, _Alloc>' 589 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:589:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const allocator_type&)-> std::vector<_Tp, _Alloc>' 607 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:607:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const allocator_type&)-> std::vector<_Tp, _Alloc>' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:625:7: note: template argument deduction/substitution failed: grid.cpp:15:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 15 | vector[last] = temp; | ^~~~ In file included from /usr/include/c++/10/vector:67, from grid.h:2, from grid.cpp:1: /usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>' 653 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:653:2: note: template argument deduction/substitution failed: grid.cpp:15:19: note: candidate expects 3 arguments, 1 provided 15 | vector[last] = temp; | ^~~~ grid.cpp:15:19: note: explicit deduction guides not considered for copy-initialization