# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
425504 | 2021-06-13T06:14:19 Z | chirathnirodha | Jelly Flavours (IOI20_jelly) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
//Coded by Chirath Nirodha #include<bits/stdc++.h> using namespace std; #include "jelly.h" #define MP make_pair #define PB push_back #define F first #define S second typedef long long ll; bool sub4(vector<int> v){ for(int i=1;i<v.size();i++)if(v[i]!=v[i-1])return false; return true; } bool sub5(vector<int> v,vector<int> w){ for(int i=0;i<v.size();i++)if(v[i]!=w[i])return false; return true; } int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) { int n = a.size(); if(y==0){ vector<int> dp[n+1][x+1]; for(int i=0;i<=x;i++)dp[0][i]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=x;j++){ dp[i][j]=dp[i-1][j]; if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); } } return dp[n][x]; } else if(sub4(b)){ vector<int> dp[n+1][x+1]; for(int i=0;i<=x;i++)dp[0][i]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=x;j++){ dp[i][j]=dp[i-1][j]; if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); } } int ans=dp[n][x]; ans=min(n,ans+y/b[0]); return ans; } else if(sub5(a,b)){ x+=y; vector<int> dp[n+1][x+1]; for(int i=0;i<=x;i++)dp[0][i]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=x;j++){ dp[i][j]=dp[i-1][j]; if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); } } return dp[n][x]; } else{ vector<int> dp[n+1][x+1][y+1]; for(int i=0;i<=x;i++)for(int j=0;j<=y;j++)dp[0][x][y]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=x;j++){ for(int k=0;k<=y;k++){ dp[i][j][k]=dp[i-1][j][k]; if(j-a[i-1]>=0)dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-a[i-1]][k]+1); if(k-b[i-1]>=0)dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k-b[i-1]]+1); } } } return dp[n][x][y]; } return n; }
Compilation message
jelly.cpp: In function 'bool sub4(std::vector<int>)': jelly.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 12 | for(int i=1;i<v.size();i++)if(v[i]!=v[i-1])return false; | ~^~~~~~~~~ jelly.cpp: In function 'bool sub5(std::vector<int>, std::vector<int>)': jelly.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 16 | for(int i=0;i<v.size();i++)if(v[i]!=w[i])return false; | ~^~~~~~~~~ jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)': jelly.cpp:23:33: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int') 23 | for(int i=0;i<=x;i++)dp[0][i]=0; | ^ 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 /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from jelly.cpp:2: /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 'int' 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 /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from jelly.cpp:2: /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 'int' 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 'int' to 'std::initializer_list<int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ jelly.cpp:27:57: error: no match for 'operator+' (operand types are 'std::vector<int>' and 'int') 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ~~~~~~~~~~~~~~~^~ | | | | | int | std::vector<int> In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from jelly.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:508:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)' 508 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:508:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from jelly.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:1540:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&)' 1540 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1540:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6022:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 6022 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6022:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:56, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.tcc:1160:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 1160 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.tcc:1160:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: mismatched types 'const _CharT*' and 'std::vector<int>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:56, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.tcc:1180:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 1180 | operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.tcc:1180:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6059:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 6059 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6059:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6075:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 6075 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6075:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6087:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 6087 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6087:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6093:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6093 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6093:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6099:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6099 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6099:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6121:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6121 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6121:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: mismatched types 'const _CharT*' and 'std::vector<int>' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from jelly.cpp:2: /usr/include/c++/10/bits/basic_string.h:6127:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6127 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6127:5: note: template argument deduction/substitution failed: jelly.cpp:27:58: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 27 | if(j-a[i-1]>=0)dp[i][j]=max(dp[i][j],dp[i][j-a[i-1]]+1); | ^ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr