結果

問題 No.662 スロットマシーン
ユーザー nebukuro09nebukuro09
提出日時 2018-03-29 10:33:18
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,406 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 161,092 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-03 19:02:47
合計ジャッジ時間 7,496 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    int[string] marks;
    int[] rewards = new int[5];

    foreach (i; 0..5) {
        auto s = readln.split;
        marks[s[0]] = i;
        rewards[i] = s[1].to!int;
    }
    
    auto N1 = readln.chomp.to!int;
    auto A = N1.iota.map!(_ => marks[readln.chomp]).array;
    auto N2 = readln.chomp.to!int;
    auto B = N2.iota.map!(_ => marks[readln.chomp]).array;
    auto N3 = readln.chomp.to!int;
    auto C = N3.iota.map!(_ => marks[readln.chomp]).array;

    auto cnt = new int[5];
    foreach (c; C) cnt[c] += 1;

    long tot = 0;
    auto ans = new long[5];

    foreach (i; 0..N1) {
        foreach (j; 0..N2) {
            int a1 = A[i], a2 = A[(i+1)%N1], a3 = A[(i+2)%N1];
            int b1 = B[j], b2 = B[(j+1)%N2], b3 = B[(j+2)%N2];
            if (a1 == b1) tot += cnt[a1] * rewards[a1], ans[a1] += 1;
            if (a1 == b2) tot += cnt[a1] * rewards[a1], ans[a1] += 1;
            if (a2 == b2) tot += cnt[a2] * rewards[a2], ans[a2] += 1;
            if (a3 == b2) tot += cnt[a3] * rewards[a3], ans[a3] += 1;
            if (a3 == b3) tot += cnt[a3] * rewards[a3], ans[a3] += 1;
        }
    }

    writefln("%.09f", 1.0L * tot / (N1 * N2 * N3));
    5.iota.each!(i => writeln(ans[i]));
}
0