結果
問題 | No.662 スロットマシーン |
ユーザー |
|
提出日時 | 2018-03-29 10:33:18 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,406 bytes |
コンパイル時間 | 2,782 ms |
コンパイル使用メモリ | 161,540 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-13 00:08:32 |
合計ジャッジ時間 | 7,531 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 WA * 17 |
ソースコード
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]));}