# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306291 | tatyam | Painting Walls (APIO20_paint) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
using std::vector;
void chmin(int& a, int b){ if(a > b) a = b; }
void chmax(int& a, int b){ if(a < b) a = b; }
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B){
vector range(M, pair{-1, -1});
vector next(N, 0);
vector trB(K, vector<int>{});
for(int i = 0; i < M; i++) for(int c : B[i]) trB[c].push_back(i);
for(int i = N; i--; ){
const int c = C[i];
for(int b : trB[c]){
int x = (b - i) % M;
if(x < 0) x += M;
auto& [l, r] = range[x];
if(l != i + 1) r = i + 1;
l = i;
if(r - l >= M) chmax(next[i], r);
}
}
for(int i = 0; i < N - 1; i++) chmax(next[i + 1], next[i]);
for(int i = 0; i < N; i++) chmin(next[i], i + M);
int ans = 0, at = 0;
while(at < N){
if(next[at] <= at) return -1;
at = next[at];
ans++;
}
return ans;
}
Compilation message (stderr)
paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)': paint.cpp:7:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'? 7 | vector range(M, pair{-1, -1}); | ^~~~ | std::pair In file included from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/vector:60, from paint.cpp:1: /usr/include/c++/9/bits/stl_pair.h:208:12: note: 'std::pair' declared here 208 | struct pair | ^~~~ paint.cpp:7:33: error: class template argument deduction failed: 7 | vector range(M, pair{-1, -1}); | ^ paint.cpp:7:33: error: no matching function for call to 'vector()' In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:1872:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> std::vector<_ValT, _Allocator>' 1872 | vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:1872:5: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 3 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:650:2: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>' 650 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:650:2: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 3 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:622:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const allocator_type&)-> std::vector<_Tp, _Alloc>' 622 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:622:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 2 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:604:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const allocator_type&)-> std::vector<_Tp, _Alloc>' 604 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:604:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 2 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:586:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type)-> std::vector<_Tp, _Alloc>' 586 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:586:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 3 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:582:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type)-> std::vector<_Tp, _Alloc>' 582 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:582:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 3 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:572:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, const allocator_type&)-> std::vector<_Tp, _Alloc>' 572 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:572:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 2 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>' 569 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:569:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 1 argument, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:550:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>' 550 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:550:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 1 argument, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:519: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>' 519 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:519:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 3 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:507:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&)-> std::vector<_Tp, _Alloc>' 507 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:507:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 2 arguments, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:494:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const allocator_type&)-> std::vector<_Tp, _Alloc>' 494 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:494:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: candidate expects 1 argument, 0 provided 7 | vector range(M, pair{-1, -1}); | ^ In file included from /usr/include/c++/9/vector:67, from paint.cpp:1: /usr/include/c++/9/bits/stl_vector.h:484:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>' 484 | vector() = default; | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:484:7: note: template argument deduction/substitution failed: paint.cpp:7:33: note: couldn't deduce template parameter '_Tp' 7 | vector range(M, pair{-1, -1}); | ^