Submission #528074


Source Code Expand

/*{{{*/
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
typedef int8_t sbyte;
typedef uint8_t byte;
typedef uint16_t ushort;
typedef uint32_t uint;
typedef int64_t i64;
typedef uint64_t u64;
template<class T> static inline T ABS(T x) {return x < 0 ? -x : x;}
template<class T> static inline void MAZ(T &a, const T &b) {if(a < b) a = b;}
template<class T> static inline void MIZ(T &a, const T &b) {if(b < a) a = b;}
/*}}}*/

static const auto INF = 1e100;

static double DP[101][101][101][4];

int main() {
	int n1, n2, n3, p1, p2, p3;
	cin >> n1 >> n2 >> n3;
	cin >> p1 >> p2 >> p3;
	auto P1 = p1 / 100., Q1 = (100 - p1) / 100.;
	auto P2 = p2 / 100., Q2 = (100 - p2) / 100.;
	auto P3 = p3 / 100., Q3 = (100 - p3) / 100.;
	for(auto i = 0; i <= n1; i++) {
		for(auto j = 0; j <= n2; j++) {
			for(auto k = 0; k <= n3; k++) {
				if(i + j + k == 0) continue;
				auto d0 = INF;
				if(i != 0) MIZ(d0, DP[i - 1][j][k][1] + 1 / P1);
				if(j != 0) MIZ(d0, DP[i][j - 1][k][1] + 1 / P2);
				if(k != 0) MIZ(d0, DP[i][j][k - 1][1] + 1 / P3);
				DP[i][j][k][0] = d0;
				auto d1 = INF;
				if(i != 0) MIZ(d1, P1 * DP[i - 1][j][k][2] + Q1 * d0);
				if(j != 0) MIZ(d1, P2 * DP[i][j - 1][k][2] + Q2 * d0);
				if(k != 0) MIZ(d1, P3 * DP[i][j][k - 1][2] + Q3 * d0);
				DP[i][j][k][1] = d1;
				auto d2 = INF;
				if(i != 0) MIZ(d2, P1 * DP[i - 1][j][k][0] + Q1 * d0);
				if(j != 0) MIZ(d2, P2 * DP[i][j - 1][k][3] + Q2 * d0);
				if(k != 0) MIZ(d2, P3 * DP[i][j][k - 1][3] + Q3 * d0);
				DP[i][j][k][2] = d2;
				auto d3 = INF;
				if(i != 0) MIZ(d3, P1 * DP[i - 1][j][k][0] + Q1 * d0);
				if(j != 0) MIZ(d3, P2 * DP[i][j - 1][k][0] + Q2 * d0);
				if(k != 0) MIZ(d3, P3 * DP[i][j][k - 1][0] + Q3 * d0);
				DP[i][j][k][3] = d3;
			}
		}
	}
	printf("%.15f\n", DP[n1][n2][n3][0]);
	return 0;
}

Submission Info

Submission Time
Task E - Game
User arosusti
Language C++11 (GCC 4.8.1)
Score 100
Code Size 2265 Byte
Status AC
Exec Time 130 ms
Memory 33240 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 5
AC × 22
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt, subtask1_manual_01.txt, subtask1_manual_02.txt, subtask1_manual_03.txt, subtask1_manual_04.txt, subtask1_manual_05.txt, subtask1_manual_06.txt, subtask1_manual_07.txt, subtask1_random_01.txt, subtask1_random_02.txt, subtask1_random_03.txt, subtask1_random_04.txt, subtask1_random_05.txt, subtask1_random_06.txt, subtask1_random_07.txt, subtask1_random_08.txt, subtask1_random_09.txt, subtask1_random_10.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 30 ms 988 KB
subtask0_sample_02.txt AC 114 ms 33240 KB
subtask0_sample_03.txt AC 28 ms 1044 KB
subtask0_sample_04.txt AC 27 ms 992 KB
subtask0_sample_05.txt AC 29 ms 1556 KB
subtask1_manual_01.txt AC 28 ms 920 KB
subtask1_manual_02.txt AC 26 ms 924 KB
subtask1_manual_03.txt AC 27 ms 1048 KB
subtask1_manual_04.txt AC 127 ms 33236 KB
subtask1_manual_05.txt AC 130 ms 33116 KB
subtask1_manual_06.txt AC 104 ms 31512 KB
subtask1_manual_07.txt AC 104 ms 27412 KB
subtask1_random_01.txt AC 76 ms 21912 KB
subtask1_random_02.txt AC 43 ms 5804 KB
subtask1_random_03.txt AC 50 ms 10648 KB
subtask1_random_04.txt AC 32 ms 1744 KB
subtask1_random_05.txt AC 41 ms 5856 KB
subtask1_random_06.txt AC 73 ms 20056 KB
subtask1_random_07.txt AC 43 ms 6248 KB
subtask1_random_08.txt AC 45 ms 5992 KB
subtask1_random_09.txt AC 44 ms 6936 KB
subtask1_random_10.txt AC 45 ms 5196 KB