結果
問題 | No.662 スロットマシーン |
ユーザー |
![]() |
提出日時 | 2025-03-20 20:41:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 1,718 bytes |
コンパイル時間 | 181 ms |
コンパイル使用メモリ | 82,544 KB |
実行使用メモリ | 77,628 KB |
最終ジャッジ日時 | 2025-03-20 20:41:50 |
合計ジャッジ時間 | 2,559 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
from collections import defaultdict # Read symbol and coin data symbol_coin = {} symbol_order = [] for _ in range(5): s, c = input().split() c = int(c) symbol_coin[s] = c symbol_order.append(s) # Read reels data n1 = int(input()) col1 = [input().strip() for _ in range(n1)] n2 = int(input()) col2 = [input().strip() for _ in range(n2)] n3 = int(input()) col3 = [input().strip() for _ in range(n3)] # Count occurrences for each symbol in each column def count_symbols(reel): counts = defaultdict(int) for s in reel: counts[s] += 1 return counts col1_counts = count_symbols(col1) col2_counts = count_symbols(col2) col3_counts = count_symbols(col3) # Define lines with their respective column offsets (dx1, dx2, dx3) lines = [ [0, 0, 0], # Top horizontal [1, 1, 1], # Middle horizontal [2, 2, 2], # Bottom horizontal [0, 1, 2], # Diagonal top-left to bottom-right [2, 1, 0] # Diagonal top-right to bottom-left ] # Initialize total occurrences for each symbol symbol_total = defaultdict(int) # Process each line for dx1, dx2, dx3 in lines: for symbol in symbol_coin: cnt1 = col1_counts.get(symbol, 0) cnt2 = col2_counts.get(symbol, 0) cnt3 = col3_counts.get(symbol, 0) total = cnt1 * cnt2 * cnt3 symbol_total[symbol] += total # Calculate expected value total_patterns = n1 * n2 * n3 coin_sum = sum(symbol_total[s] * symbol_coin[s] for s in symbol_total) expected = coin_sum / total_patterns # Prepare the results for U_i in the order of symbol_order results = [symbol_total.get(s, 0) for s in symbol_order] # Output expected and U_i print("{0:.6f}".format(expected)) for res in results: print(res)