結果

問題 No.662 スロットマシーン
ユーザー IL_mstaIL_msta
提出日時 2018-03-09 23:25:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 3,779 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 119,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 03:01:29
合計ジャッジ時間 2,283 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
bool flag = false;
	vector<string> ega(5);
	vector<LL> out(5);

if(flag){
	for(int i=0;i<5;++i){
		ega[i] = "A";
		out[i] = 1001;
	}
}else{
	for(int i=0;i<5;++i){
		cin>> ega[i] >> out[i];
	}
}

	vector<int> num(3);
	vector< vector<LL> > ree(3,vector<LL>(125,0));
	for(int i=0;i<3;++i){
		if(flag){
			num[i] = 5000;
		}else{
			cin >> num[i];
		}
		
		vector<LL> A(num[i]);
		string str;
		for(int j=0;j<num[i];++j){
			if(flag){
				str = "A";
			}else{
				cin >> str;
			}
			for(int k=0;k<5;++k){
				if( str == ega[k] ){
					A[j] = k;
					break;
				}
			}
		}
		for(int j=0;j<num[i];++j){
			int a = j;
			int b = (j+1)%num[i];
			int c = (j+2)%num[i];
			int val = A[a] + 5*A[b] + 25*A[c];
			ree[i][val]++;
		}
	}
	///////////
	vector<vector<int> > game(3,vector<int>(3));
	vector<LL> atari(5,0);
	LL ALL = 0;
	/*
	LD ALL_TRY = num[0]*num[1]*num[2];
	//////!?
	*/
	LD ALL_TRY = num[0]*num[1];
	ALL_TRY = ALL_TRY * num[2];
	LD ansP = 0;

	for(int a=0;a<125;++a){
		if( ree[0][a] == 0 ) continue;
		for(int b=0;b<125;++b){
			if( ree[1][b] == 0 ) continue;
			for(int c=0;c<125;++c){
				if( ree[2][c] == 0 ) continue;
				int ter = a;game[0][0] = ter%5;
				ter /= 5;game[1][0] = ter%5;
				ter /=5;game[2][0] = ter;

				ter = b;game[0][1] = ter%5;
				ter /= 5;game[1][1] = ter%5;
				ter /=5;game[2][1] = ter;

				ter = c;game[0][2] = ter%5;
				ter /= 5;game[1][2] = ter%5;
				ter /=5;game[2][2] = ter;
				if( game[0][0]==game[0][1] && game[0][1]==game[0][2] ){
					int kind = game[0][0];
					LL kaisuu = ree[0][a]*ree[1][b]*ree[2][c];
					atari[kind] += kaisuu;
					ALL += kaisuu*out[kind];
					ansP += (LD)1.0*kaisuu*out[kind]/ALL_TRY;
				}

				if( game[1][0]==game[1][1] && game[1][1]==game[1][2] ){
					int kind = game[1][0];
					LL kaisuu = ree[0][a]*ree[1][b]*ree[2][c];
					atari[kind] += kaisuu;
					ALL += kaisuu*out[kind];
					ansP += (LD)1.0*kaisuu*out[kind]/ALL_TRY;
				}

				if( game[2][0]==game[2][1] && game[2][1]==game[2][2] ){
					int kind = game[2][0];
					LL kaisuu = ree[0][a]*ree[1][b]*ree[2][c];
					atari[kind] += kaisuu;
					ALL += kaisuu*out[kind];
					ansP += (LD)1.0*kaisuu*out[kind]/ALL_TRY;
				}

				if( game[0][0]==game[1][1] && game[1][1]==game[2][2] ){
					int kind = game[0][0];
					LL kaisuu = ree[0][a]*ree[1][b]*ree[2][c];
					atari[kind] += kaisuu;
					ALL += kaisuu*out[kind];
					ansP += (LD)1.0*kaisuu*out[kind]/ALL_TRY;
				}

				if( game[2][0]==game[1][1] && game[1][1]==game[0][2] ){
					int kind = game[1][1];
					LL kaisuu = ree[0][a]*ree[1][b]*ree[2][c];
					atari[kind] += kaisuu;
					ALL += kaisuu*out[kind];
					ansP += (LD)1.0*kaisuu*out[kind]/ALL_TRY;
				}
			}
		}
	}
	
	
	cout << ansP << endl;
	for(int i=0;i<5;++i){
		cout << atari[i] << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()
0