結果

問題 No.662 スロットマシーン
ユーザー nebukuro09nebukuro09
提出日時 2018-03-29 10:36:29
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 488 ms / 2,000 ms
コード長 1,434 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 161,140 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 19:03:12
合計ジャッジ時間 7,387 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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] += cnt[a1];
            if (a1 == b2) tot += cnt[a1] * rewards[a1], ans[a1] += cnt[a1];
            if (a2 == b2) tot += cnt[a2] * rewards[a2], ans[a2] += cnt[a2];
            if (a3 == b2) tot += cnt[a3] * rewards[a3], ans[a3] += cnt[a3];
            if (a3 == b3) tot += cnt[a3] * rewards[a3], ans[a3] += cnt[a3];
        }
    }

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