結果

問題 No.402 最も海から遠い場所
ユーザー 14番14番
提出日時 2016-07-23 00:16:18
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 2,457 bytes
コンパイル時間 2,297 ms
コンパイル使用メモリ 110,848 KB
実行使用メモリ 43,776 KB
最終ジャッジ日時 2024-04-24 06:53:02
合計ジャッジ時間 7,532 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
43,776 KB
testcase_01 AC 34 ms
19,712 KB
testcase_02 AC 99 ms
22,528 KB
testcase_03 AC 32 ms
19,200 KB
testcase_04 AC 36 ms
19,584 KB
testcase_05 AC 37 ms
19,328 KB
testcase_06 AC 37 ms
19,456 KB
testcase_07 AC 34 ms
19,584 KB
testcase_08 AC 34 ms
19,328 KB
testcase_09 AC 35 ms
19,712 KB
testcase_10 AC 34 ms
19,200 KB
testcase_11 AC 47 ms
20,480 KB
testcase_12 AC 37 ms
19,584 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;



class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

        int H = inpt[0];
        int W = inpt[1];

        Dictionary<int, Dictionary<int, int>> step = new Dictionary<int, Dictionary<int, int>>();

        char[,] map = new char[H, W];

        for(int i=0; i<H; i++) {
            if(!step.ContainsKey(i)) {
                step.Add(i, new Dictionary<int, int>());
            }
            string tmp = Reader.ReadLine();
            for(int j=0; j<tmp.Length; j++) {
                map[i,j] = tmp[j];
                if(tmp[j] == '.') {
                    step[i][j] = 0;
                }
                else if(i==0 || i == H-1 || j == 0 || j == W-1) {
                    step[i][j] = 1;
                }
            }
        }
        for(int i=0; i<=H*W/4; i++) {
            int[] yKeys = step.Where(a=>a.Value.Count(b=>b.Value == i) > 0).Select(a=>a.Key).ToArray();

            yKeys.ToList().ForEach(a=>{
                step[a].Where(b=>b.Value == i).ToList().ForEach(b=>{
                    for(int j=Math.Max(0, a-1); j<=Math.Min(H-1, a+1); j++) {
                        for(int k=Math.Max(0, b.Key - 1); k<=Math.Min(W-1, b.Key+1); k++) {
                            if((!step[j].ContainsKey(k)) && map[j,k] == '#')  {
                                step[j][k] = i+1;
                            }
                        }
                    } 
                });
            });

        }

        int ans = step.Max(a=>a.Value.Max(b=>b.Value));
        Console.WriteLine(ans);



    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

8 8
.#..#...
.######.
#####...
#####.#.
########
######.#
#####...
...####.


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0