結果
問題 | No.659 徘徊迷路 |
ユーザー | AreTrash |
提出日時 | 2018-03-03 00:10:15 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,581 bytes |
コンパイル時間 | 1,005 ms |
コンパイル使用メモリ | 109,568 KB |
実行使用メモリ | 33,316 KB |
最終ジャッジ日時 | 2024-06-23 00:21:32 |
合計ジャッジ時間 | 11,249 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 521 ms
29,096 KB |
testcase_03 | RE | - |
testcase_04 | AC | 530 ms
29,092 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 471 ms
31,268 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 162 ms
29,096 KB |
testcase_13 | WA | - |
testcase_14 | AC | 554 ms
28,960 KB |
testcase_15 | AC | 1,088 ms
27,208 KB |
testcase_16 | 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.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 = 30000d; 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; } } }