結果

問題 No.662 スロットマシーン
ユーザー tkmst201
提出日時 2021-01-19 09:40:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,660 bytes
コンパイル時間 1,979 ms
コンパイル使用メモリ 203,968 KB
最終ジャッジ日時 2025-01-18 02:33:25
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |                 scanf("%d", &N[i]);
      |                 ~~~~~^~~~~~~~~~~~~

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0