結果

問題 No.662 スロットマシーン
ユーザー IL_msta
提出日時 2018-03-09 23:25:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 3,779 bytes
コンパイル時間 1,337 ms
コンパイル使用メモリ 119,348 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-10 19:40:02
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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);////coutcerr
solve();
}
#pragma endregion //main()
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0