結果

問題 No.662 スロットマシーン
ユーザー tkmst201tkmst201
提出日時 2021-01-19 09:40:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,660 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 211,280 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 06:16:20
合計ジャッジ時間 4,017 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
4,380 KB
testcase_01 AC 17 ms
4,380 KB
testcase_02 AC 16 ms
4,376 KB
testcase_03 AC 17 ms
4,376 KB
testcase_04 AC 17 ms
4,376 KB
testcase_05 AC 17 ms
4,380 KB
testcase_06 AC 17 ms
4,384 KB
testcase_07 AC 17 ms
4,380 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 19 ms
4,380 KB
testcase_10 AC 19 ms
4,380 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 19 ms
4,376 KB
testcase_14 AC 19 ms
4,376 KB
testcase_15 AC 19 ms
4,380 KB
testcase_16 AC 17 ms
4,380 KB
testcase_17 AC 19 ms
4,376 KB
testcase_18 AC 19 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	map<string, int> conv;
	vector<int> coin(5);
	REP(i, 5) {
		string S;
		cin >> S >> coin[i];
		conv[S] = i;
	}
	int N[3];
	vector<int> A[3];
	REP(i, 3) {
		scanf("%d", &N[i]);
		A[i].resize(N[i]);
		REP(j, N[i]) {
			string S;
			cin >> S;
			A[i][j] = conv[S];
		}
	}
	
	int cnt[3][125] {};
	REP(i, 3) {
		REP(j, N[i]) {
			const int p1 = A[i][j], p2 = A[i][(j + 1) % N[i]], p3 = A[i][(j + 2) % N[i]];
			++cnt[i][p1 * 25 + p2 * 5 + p3];
		}
	}
	
	ll sum = 0, ans[5] {};
	REP(i, 125) REP(j, 125) REP(k, 125) {
		const int a[3][3] = {
			{ i/25,  j/25,  k/25 },
			{ i/5%5, j/5%5, k%5 },
			{ i%5,   j%5,   k%5 },
		};
		ll p = (ll)cnt[0][i] * cnt[1][j] * cnt[2][k];
		REP(l, 3) if (a[l][0] == a[l][1] && a[l][1] == a[l][2]) {
			ans[a[l][0]] += p;
			sum += coin[a[l][0]] * p;
		}
		int c = a[0][0] == a[1][1] && a[1][1] == a[2][2];
		c += a[2][0] == a[1][1] && a[1][1] == a[0][2];
		ans[a[1][1]] += c * p;
		sum += c * coin[a[1][1]] * p;
	}
	printf("%.16f\n", (double)sum / ((ll)N[0] * N[1] * N[2]));
	REP(i, 5) cout << ans[i] << endl;
}
0