Language: C++



Time limit
    2000 ms
Memory limit
    1048576 kB
Source
    Educational DP Contest / DP まとめコンテスト

Choose a description for participants:
   System Crawler 2019-10-04
I - Coins AtCoder - 4530
All Copyright Reserved © 2010-2019 Xu Han
Server Time: 2019-10-10 09:05:27 UTC+7
#22154523 | coderbodoh's solution for [AtCoder-4530] [Problem I]
Status
	Compilation Error
Length
	942
Lang
	C++14 (GCC 5.3.0)
Submitted
	2019-10-10 09:05:06
Shared
	
RemoteRunId
	7923756

./Main.cpp:1:11: error: "|" is not a valid filename
#22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
^
./Main.cpp:1:23: warning: missing terminating ' character
#22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
^
./Main.cpp:7:13: error: too many decimal points in number
C++14 (GCC 5.3.0)
^
./Main.cpp:9:13: error: invalid digit "8" in octal constant
2019-10-10 08:31:26
^
./Main.cpp:2:1: error: ‘Status’ does not name a type
Status
^
Select Code

#22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
Status
	Wrong Answer
Length
	706
Lang
	C++14 (GCC 5.3.0)
Submitted
	2019-10-10 08:31:26
Shared
	
RemoteRunId
	7923536
17.0 / 33.0
Select Code

#include <bits/stdc++.h>
using namespace std;

int N;
double p[3000], head[3000], tail[3000];
double dp[3000][3000];

double f(int n, int m) {
	if (n==0) {
		if (m==0) return 1;
		else return 0;
	}
	if (m==n) return head[n];
	if (m==0) return tail[n];
	if (dp[n][m] > -1) return dp[n][m];
	dp[n][m] = p[n]*f(n-1, m-1) + (1-p[n])*f(n-1, m);
	//cout << n << " " << m << " " << dp[n][m] << endl;
	return dp[n][m];
}

int main () {
	cin >> N;
	head[0] = 1;
	tail[0] = 1;
	for(int i=1; i<=N; i++) {
		for(int j=0; j<=N; j++)
			dp[i][j] = -1;
		cin >> p[i];
		head[i] = head[i-1]*p[i];
		tail[i] = tail[i-1]*(1-p[i]);
	}
	double ans = 0;
	for(int i=(N+1)/2; i<=N; i++)
		ans += f(N, i);
	cout << fixed << setprecision(10) << ans << endl;
}

Compiler output:
a.cc:13:24: error: extended character © is not valid in an identifier
   13 | All Copyright Reserved © 2010-2019 Xu Han
      |                        ^
a.cc:14:25: error: invalid digit "9" in octal constant
   14 | Server Time: 2019-10-10 09:05:27 UTC+7
      |                         ^~
a.cc:15:11: error: "|" is not a valid filename
   15 | #22154523 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |           ^
a.cc:15:23: warning: missing terminating ' character
   15 | #22154523 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |                       ^
a.cc:21:20: error: too many decimal points in number
   21 |         C++14 (GCC 5.3.0)
      |                    ^~~~~
a.cc:23:20: error: invalid digit "9" in octal constant
   23 |         2019-10-10 09:05:06
      |                    ^~
a.cc:30:11: error: "|" is not a valid filename
   30 | #22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |           ^
a.cc:30:23: warning: missing terminating ' character
   30 | #22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |                       ^
a.cc:32:47: warning: missing terminating ' character
   32 | ./Main.cpp:1:23: warning: missing terminating ' character
      |                                               ^
a.cc:32:47: error: missing terminating ' character
   32 | ./Main.cpp:1:23: warning: missing terminating ' character
      |                                               ^~~~~~~~~~~
a.cc:33:11: error: "|" is not a valid filename
   33 | #22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |           ^
a.cc:33:23: warning: missing terminating ' character
   33 | #22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |                       ^
a.cc:36:12: error: too many decimal points in number
   36 | C++14 (GCC 5.3.0)
      |            ^~~~~
a.cc:39:12: error: invalid digit "8" in octal constant
   39 | 2019-10-10 08:31:26
      |            ^~
a.cc:41:24: error: extended character ‘ is not valid in an identifier
   41 | ./Main.cpp:2:1: error: ‘Status’ does not name a type
      |                        ^
a.cc:41:24: error: extended character ’ is not valid in an identifier
a.cc:46:11: error: "|" is not a valid filename
   46 | #22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |           ^
a.cc:46:23: warning: missing terminating ' character
   46 | #22154310 | coderbodoh's solution for [AtCoder-4530] [Problem I]
      |                       ^
a.cc:52:20: error: too many decimal points in number
   52 |         C++14 (GCC 5.3.0)
      |                    ^~~~~
a.cc:54:20: error: invalid digit "8" in octal constant
   54 |         2019-10-10 08:31:26
      |                    ^~
a.cc:3:1: error: 'Time' does not name a type
    3 | Time limit
      | ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:62:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
  670 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
  674 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
  678 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
 1440 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
 1441 |     struct rank<_Tp[_Size]>
      |                     ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
 1441 |     struct rank<_Tp[_Size]>
      |                           ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
 2086 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
 2087 |     struct remove_extent<_Tp[_Size]>
      |                              ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
 2087 |     struct remove_extent<_Tp[_Size]>
      |                                    ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
 2099 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                   ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                         ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
 2171 |   template<std::size_t _Len>
      |            ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
 2176 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |            ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t