結果
問題 | No.309 シャイな人たち (1) |
ユーザー | eitaho |
提出日時 | 2015-12-02 15:38:46 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,262 bytes |
コンパイル時間 | 1,203 ms |
コンパイル使用メモリ | 120,172 KB |
実行使用メモリ | 29,512 KB |
最終ジャッジ日時 | 2024-09-14 07:53:34 |
合計ジャッジ時間 | 2,179 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
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 | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.IO; using System.Linq; using System.Text; using System.Collections.Generic; using System.Diagnostics; using System.Numerics; using Enu = System.Linq.Enumerable; class Program { static readonly int Threshold = 4; public void Solve() { int H = Reader.Int(), W = Reader.Int(); var Prob = Reader.IntTable(H).Select(r => r.Select(c => c / 100.0).ToArray()).ToArray(); var Val = Reader.IntTable(H).Select(r => r.Select(c => Threshold - c).ToArray()).ToArray(); Console.WriteLine("Yay!"); return; var dp = new double[1 << W]; dp[0] = 1; double ans = 0; for (int r = 0; r < H; r++) { var nextdp = new double[1 << W]; for (int prevMask = 0; prevMask < (1 << W); prevMask++) if (dp[prevMask] > 0) for (int currMask = 0; currMask < (1 << W); currMask++) { double p = dp[prevMask]; for (int c = 0; c < W; c++) if ((currMask >> c & 1) == 1) p *= Prob[r][c]; else p *= 1 - Prob[r][c]; int atLast = Simulate(Val, r, prevMask, currMask); ans += p * BitCount32(atLast); nextdp[atLast] += p; } dp = nextdp; } Console.WriteLine(ans); } private static int Simulate(int[][] Val, int r, int prevMask, int currMask) { int W = Val[0].Length; int[] pt = new int[W]; var who = new List<int>(); int stands = 0; Action<int, List<int>> Add = (w, list) => { stands += 1 << w; list.Add(w); }; for (int c = 0; c < W; c++) { if (r > 0) pt[c] = prevMask >> c & 1; pt[c] += Val[r][c] * (currMask >> c & 1); if (pt[c] >= Threshold) Add(c, who); } while (who.Count > 0) { var nextWho = new List<int>(); foreach (int c in who) { if (c - 1 >= 0 && ++pt[c - 1] == Threshold) Add(c - 1, nextWho); if (c + 1 < W && ++pt[c + 1] == Threshold) Add(c + 1, nextWho); } who = nextWho; } return stands; } static int BitCount32(int x) { x -= x >> 1 & 0x55555555; x = (x & 0x33333333) + (x >> 2 & 0x33333333); return ((x + (x >> 4) & 0x0f0f0f0f) * 0x01010101) >> 24; } } class Entry { static void Main() { new Program().Solve(); } } class Reader { private static TextReader reader = Console.In; private static readonly char[] separator = { ' ' }; private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries; private static string[] A = new string[0]; private static int i; private static void Init() { A = new string[0]; } public static void Set(TextReader r) { reader = r; Init(); } public static void Set(string file) { reader = new StreamReader(file); Init(); } public static bool HasNext() { return CheckNext(); } public static string String() { return Next(); } public static int Int() { return int.Parse(Next()); } public static long Long() { return long.Parse(Next()); } public static double Double() { return double.Parse(Next()); } public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); } public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); } public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); } public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Next()).ToArray(); } public static string Line() { return reader.ReadLine().Trim(); } private static string[] Split(string s) { return s.Split(separator, op); } private static string Next() { CheckNext(); return A[i++]; } private static bool CheckNext() { if (i < A.Length) return true; string line = reader.ReadLine(); if (line == null) return false; if (line == "") return CheckNext(); A = Split(line); i = 0; return true; } }