結果

問題 No.662 スロットマシーン
ユーザー ei1333333ei1333333
提出日時 2018-03-09 23:39:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,483 bytes
コンパイル時間 2,608 ms
コンパイル使用メモリ 206,064 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 03:44:53
合計ジャッジ時間 3,505 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long int64;

int main() {
  map< string, int > conb;
  string str[5];
  int coin[5], n[3], beet[3][5][1 << 3] = {{{}}};
  int64 comb[5] = {};

  for(int i = 0; i < 5; i++) {
    cin >> str[i] >> coin[i];
    conb[str[i]] = i;
  }

  for(int i = 0; i < 3; i++) {
    cin >> n[i];
    vector< string > name(n[i]);
    for(int j = 0; j < n[i]; j++) {
      cin >> name[j];
    }
    for(int j = 0; j < n[i]; j++) {
      int happen[5] = {};
      for(int k = 0; k < 3; k++) {
        happen[conb[name[(j + k) % n[i]]]] |= 1 << k;
      }
      for(int k = 0; k < 5; k++) {
        if(happen[k] > 0) beet[i][k][happen[k]]++;
      }
    }
  }


  double ret = 0;

  for(int i = 0; i < 5; i++) {
    for(int j = 1; j < (1 << 3); j++) {
      for(int k = 1; k < (1 << 3); k++) {
        for(int l = 1; l < (1 << 3); l++) {
          int match = 0;
          if(j & 1 && k & 1 && l & 1) ++match;
          if(j & 2 && k & 2 && l & 2) ++match;
          if(j & 4 && k & 4 && l & 4) ++match;
          if(j & 1 && k & 2 && l & 4) ++match;
          if(j & 4 && k & 2 && l & 1) ++match;
          comb[i] += 1LL * beet[0][i][j] * beet[1][i][k] * beet[2][i][l] * match;
          ret += 1.0f * beet[0][i][j] / n[0] * beet[1][i][k] / n[1] * beet[2][i][l] / n[2] * coin[i] * match;
        }
      }
    }
  }

  cout << fixed << setprecision(10);
  cout << ret << endl;
  for(int i = 0; i < 5; i++) {
    cout << comb[i] << endl;
  }
}
0