結果
問題 | No.659 徘徊迷路 |
ユーザー | AreTrash |
提出日時 | 2018-03-03 00:08:58 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,582 bytes |
コンパイル時間 | 1,128 ms |
コンパイル使用メモリ | 114,708 KB |
実行使用メモリ | 37,968 KB |
最終ジャッジ日時 | 2024-06-23 00:17:52 |
合計ジャッジ時間 | 14,488 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 1,381 ms
31,016 KB |
testcase_03 | RE | - |
testcase_04 | AC | 1,526 ms
30,752 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 1,260 ms
32,040 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
コンパイルメッセージ
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.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace No659 { public class Program { void Solve(StreamScanner ss, StreamWriter sw) { //--------------------------------- var H = ss.Next(Int); var W = ss.Next(Int); var T = ss.Next(Int); var Sy = ss.Next(Int); var Sx = ss.Next(Int); var Gy = ss.Next(Int); var Gx = ss.Next(Int); var B = ss.Next(String, H); Func<int, int, bool> isInside = (x, y) => 0 <= x && x < W && 0 <= y && y < H; int[] dx = { 0, 1, 0, -1 }; int[] dy = { 1, 0, -1, 0 }; var dl = 4; var random = new Random(); var walkEnd = (T - 100) % 100 + 100; Func<int, int, int, bool> dfs = null; dfs = (x, y, t) => { if (t == walkEnd) return x == Gx && y == Gy; var xs = new List<int>(); var ys = new List<int>(); for (var i = 0; i < dl; i++) { var cx = x + dx[i]; var cy = y + dy[i]; if (isInside(cx, cy) && B[cy][cx] == '.') { xs.Add(cx); ys.Add(cy); } } var r = random.Next(xs.Count); var nx = xs[r]; var ny = ys[r]; return dfs(nx, ny, t + 1); }; var goalCount = 0; var trialCount = 100000d; for (var i = 0; i < trialCount; i++) { if (dfs(Sx, Sy, 0)) goalCount++; } sw.WriteLine(goalCount / trialCount); //--------------------------------- } static void Main() { var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput())); var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; new Program().Solve(ss, sw); sw.Flush(); } static readonly Func<string, string> String = s => s; static readonly Func<string, int> Int = int.Parse; static readonly Func<string, long> Long = long.Parse; static readonly Func<string, double> Double = double.Parse; } public class StreamScanner { static readonly char[] Sep = {' '}; readonly Queue<string> buffer = new Queue<string>(); readonly TextReader textReader; public StreamScanner(TextReader textReader) { this.textReader = textReader; } [SuppressMessage("ReSharper", "PossibleNullReferenceException")] public T Next<T>(Func<string, T> parser) { if (buffer.Count != 0) return parser(buffer.Dequeue()); var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries); foreach (var nextString in nextStrings) buffer.Enqueue(nextString); return Next(parser); } public T[] Next<T>(Func<string, T> parser, int x) { var ret = new T[x]; for (var i = 0; i < x; ++i) ret[i] = Next(parser); return ret; } public T[][] Next<T>(Func<string, T> parser, int x, int y) { var ret = new T[y][]; for (var i = 0; i < y; ++i) ret[i] = Next(parser, x); return ret; } } }