# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
398083 | 2021-05-03T16:01:53 Z | ivasvz | 캥거루 (CEOI16_kangaroo) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
// stefdasca's solution * CEOI 16-Kangaroo We can solve this with DP component - https://codeforces.com/blog/entry/47764 dp[i][j] = number of permutations of the first i numbers with j components dp[i][j] = 1, if i = 1 and j = 1 = dp[i-1][j-1] + dp[i-1][j], if i = a or i = b = dp[i-1][j+1] * j + dp[i-1][j-1] * (j - (i > a) - (i > b)), otherwise */ #include<bits/stdc++.h> #define mod 1000000007 using namespace std; typedef long long ll; int n, a, b; inline int add(int a, int b) { if(!b) return a; int x = a+b; if(x >= mod) x -= mod; else if(x < 0) x += mod; return x; } ll mul(ll a, ll b) { return (a * b) % mod; } ll dp[2002][2002]; int main() { cin >> n >> a >> b; dp[1][1] = 1; for(int i = 2; i <= n; ++i) for(int j = 1; j <= n; ++j) { if(i == a || i == b) dp[i][j] = add(dp[i-1][j-1], dp[i-1][j]); else dp[i][j] = add(mul(dp[i-1][j+1], j), mul(dp[i-1][j-1], j - (i > a) - (i > b))); } cout << dp[n][1]; return 0; }
Compilation message
kangaroo.cpp:3:14: error: expected constructor, destructor, or type conversion before numeric constant 3 | CEOI 16-Kangaroo | ^~ In file included from /usr/include/c++/9/cmath:43, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/ext/type_traits.h:162:35: error: 'bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 162 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/9/ext/type_traits.h:157:5: note: previous declaration 'template<class _Type> bool __gnu_cxx::__is_null_pointer(_Type)' 157 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/9/ext/type_traits.h:162:26: error: 'nullptr_t' is not a member of 'std' 162 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:361:26: error: 'std::size_t' has not been declared 361 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/9/type_traits:362:25: error: '_Size' was not declared in this scope 362 | struct is_array<_Tp[_Size]> | ^~~~~ /usr/include/c++/9/type_traits:362:31: error: template argument 1 is invalid 362 | struct is_array<_Tp[_Size]> | ^ /usr/include/c++/9/type_traits:560:42: error: 'nullptr_t' is not a member of 'std' 560 | struct __is_null_pointer_helper<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/9/type_traits:560:51: error: template argument 1 is invalid 560 | struct __is_null_pointer_helper<std::nullptr_t> | ^ /usr/include/c++/9/type_traits:1253:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1253 | : public integral_constant<std::size_t, alignof(_Tp)> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/9/bits/std_abs.h:38, from /usr/include/c++/9/cmath:47, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:1253:57: error: template argument 1 is invalid 1253 | : public integral_constant<std::size_t, alignof(_Tp)> { }; | ^ /usr/include/c++/9/type_traits:1253:57: note: invalid template non-type parameter /usr/include/c++/9/type_traits:1258:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1258 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/9/bits/std_abs.h:38, from /usr/include/c++/9/cmath:47, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:1258:46: error: template argument 1 is invalid 1258 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/9/type_traits:1258:46: note: invalid template non-type parameter /usr/include/c++/9/type_traits:1260:26: error: 'std::size_t' has not been declared 1260 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/9/type_traits:1261:21: error: '_Size' was not declared in this scope 1261 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/9/type_traits:1261:27: error: template argument 1 is invalid 1261 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/9/type_traits:1262:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1262 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/9/bits/std_abs.h:38, from /usr/include/c++/9/cmath:47, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:1262:65: error: template argument 1 is invalid 1262 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/9/type_traits:1262:65: note: invalid template non-type parameter /usr/include/c++/9/type_traits:1266:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1266 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/9/bits/std_abs.h:38, from /usr/include/c++/9/cmath:47, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:1266:65: error: template argument 1 is invalid 1266 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/9/type_traits:1266:65: note: invalid template non-type parameter /usr/include/c++/9/type_traits:1271:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1271 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/9/bits/std_abs.h:38, from /usr/include/c++/9/cmath:47, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:1271:46: error: template argument 1 is invalid 1271 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/9/type_traits:1271:46: note: invalid template non-type parameter /usr/include/c++/9/type_traits:1273:42: error: 'std::size_t' has not been declared 1273 | template<typename _Tp, unsigned _Uint, std::size_t _Size> | ^~~ /usr/include/c++/9/type_traits:1274:23: error: '_Size' was not declared in this scope 1274 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/9/type_traits:1274:36: error: template argument 1 is invalid 1274 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/9/type_traits:1275:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1275 | : public integral_constant<std::size_t, | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/9/bits/std_abs.h:38, from /usr/include/c++/9/cmath:47, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:1276:24: error: '_Size' was not declared in this scope 1276 | _Uint == 0 ? _Size : extent<_Tp, | ^~~~~ /usr/include/c++/9/type_traits:1277:28: error: template argument 1 is invalid 1277 | _Uint - 1>::value> | ^ /usr/include/c++/9/type_traits:1277:28: note: invalid template non-type parameter /usr/include/c++/9/type_traits:1282:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1282 | : public integral_constant<std::size_t, | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/9/bits/std_abs.h:38, from /usr/include/c++/9/cmath:47, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/9/bits/move.h:55, from /usr/include/c++/9/bits/stl_pair.h:59, from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/type_traits:1284:31: error: template argument 1 is invalid 1284 | _Uint - 1>::value> | ^ /usr/include/c++/9/type_traits:1284:31: note: invalid template non-type parameter /usr/include/c++/9/type_traits:1838:26: error: 'std::size_t' has not been declared 1838 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/9/type_traits:1839:30: error: '_Size' was not declared in this scope 1839 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/9/type_traits:1839:36: error: template argument 1 is invalid 1839 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/9/type_traits:1851:26: error: 'std::size_t' has not been declared 1851 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/9/type_traits:1852:35: error: '_Size' was not declared in this scope 1852 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/9/type_traits:1852:41: error: template argument 1 is invalid 1852 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/9/type_traits:1910:12: error: 'std::size_t' has not been declared 1910 | template<std::size_t _Len> | ^~~ /usr/include/c++/9/type_traits:1915:23: error: '_Len' was not declared in this scope 1915 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/9/type_traits:1930:12: error: 'std::size_t' has not been declared 1930 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/9/type_traits:1930:30: error: 'std::size_t' has not been declared 1930 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/9/type_traits:1931:48: error: '_Len' was not declared in this scope 1931 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/9/type_traits:1931:52: error: template argument 1 is invalid 1931 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/9/type_traits:1936:23: error: '_Len' was not declared in this scope 1936 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/9/type_traits:1937:37: error: '_Align' was not declared in this scope 1937 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/bits/stl_pair.h:86:12: error: 'std::size_t' has not been declared 86 | template<std::size_t...> | ^~~ /usr/include/c++/9/bits/stl_pair.h:434:36: error: 'std::size_t' has not been declared 434 | template<typename... _Args1, std::size_t... _Indexes1, | ^~~ /usr/include/c++/9/bits/stl_pair.h:435:36: error: 'std::size_t' has not been declared 435 | typename... _Args2, std::size_t... _Indexes2> | ^~~ /usr/include/c++/9/bits/stl_pair.h:437:27: error: '_Indexes1' was not declared in this scope 437 | _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); | ^~~~~~~~~ /usr/include/c++/9/bits/stl_pair.h:437:36: error: expected parameter pack before '...' 437 | _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); | ^~~ /usr/include/c++/9/bits/stl_pair.h:437:39: error: template argument 1 is invalid 437 | _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); | ^ /usr/include/c++/9/bits/stl_pair.h:437:55: error: '_Indexes2' was not declared in this scope 437 | _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); | ^~~~~~~~~ /usr/include/c++/9/bits/stl_pair.h:437:64: error: expected parameter pack before '...' 437 | _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); | ^~~ /usr/include/c++/9/bits/stl_pair.h:437:67: error: template argument 1 is invalid 437 | _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); | ^ In file included from /usr/include/c++/9/bits/stl_algobase.h:65, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/bits/stl_iterator_base_types.h:116:67: error: 'ptrdiff_t' does not name a type 116 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:65, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'? +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- In file included from /usr/include/c++/9/bits/stl_algobase.h:65, from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from kangaroo.cpp:10: /usr/include/c++/9/bits/stl_iterator_base_types.h:182:15: error: 'ptrdiff_t' does not name a type 182 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/9/bits/stl_iterator_base_types.h:182:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'? /usr/include/c++/9/bits/stl_iterator_base_types.h:193:15: error: 'ptrdiff_t' does not name a type 193 | typedef ptrdiff_t difference_type; |