結果
問題 | No.402 最も海から遠い場所 |
ユーザー | 明智重蔵 |
提出日時 | 2016-09-10 13:40:25 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 9,547 bytes |
コンパイル時間 | 1,037 ms |
コンパイル使用メモリ | 113,376 KB |
実行使用メモリ | 76,056 KB |
最終ジャッジ日時 | 2024-04-28 06:44:16 |
合計ジャッジ時間 | 6,909 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
25,088 KB |
testcase_01 | AC | 25 ms
19,968 KB |
testcase_02 | AC | 27 ms
19,840 KB |
testcase_03 | AC | 26 ms
19,968 KB |
testcase_04 | AC | 26 ms
19,840 KB |
testcase_05 | AC | 27 ms
19,840 KB |
testcase_06 | AC | 26 ms
19,968 KB |
testcase_07 | AC | 29 ms
19,840 KB |
testcase_08 | AC | 27 ms
19,584 KB |
testcase_09 | AC | 25 ms
19,840 KB |
testcase_10 | AC | 26 ms
19,968 KB |
testcase_11 | AC | 27 ms
19,712 KB |
testcase_12 | AC | 26 ms
19,968 KB |
testcase_13 | AC | 29 ms
19,968 KB |
testcase_14 | AC | 28 ms
19,584 KB |
testcase_15 | AC | 38 ms
20,640 KB |
testcase_16 | AC | 55 ms
21,248 KB |
testcase_17 | AC | 294 ms
41,216 KB |
testcase_18 | TLE | - |
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.
ソースコード
using System; using System.Collections.Generic; using System.Linq; //YukiCoder402 最も海から遠い場所 //http://yukicoder.me/problems/no/402 class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("8 8"); WillReturn.Add(".#..#..."); WillReturn.Add(".######."); WillReturn.Add("#####..."); WillReturn.Add("#####.#."); WillReturn.Add("########"); WillReturn.Add("######.#"); WillReturn.Add("#####..."); WillReturn.Add("...####."); //3 } else if (InputPattern == "Input2") { WillReturn.Add("7 7"); WillReturn.Add("#######"); WillReturn.Add("#######"); WillReturn.Add("#######"); WillReturn.Add("#######"); WillReturn.Add("#.#####"); WillReturn.Add("#..####"); WillReturn.Add("#######"); //3 } else if (InputPattern == "Input3") { WillReturn.Add("60 60"); WillReturn.Add("............................................................"); WillReturn.Add("............................................................"); WillReturn.Add("........................................#...............##.."); WillReturn.Add(".......................................####............##..."); WillReturn.Add(".........................................##...........##...."); WillReturn.Add(".........................................###........#......."); WillReturn.Add(".........................................#####...#..#......."); WillReturn.Add(".........................................#########....#....."); WillReturn.Add("........................................###########........."); WillReturn.Add("........................................#############......."); WillReturn.Add(".....................................##.##########.........."); WillReturn.Add("......................................#########............."); WillReturn.Add(".....................................#########.............."); WillReturn.Add("....................................##.#...###.............."); WillReturn.Add("...................................###.......#.............."); WillReturn.Add(".....................................###...................."); WillReturn.Add(".....................................#......................"); WillReturn.Add(".......................................##..................."); WillReturn.Add("......................................#.#..................."); WillReturn.Add(".....................................####..................."); WillReturn.Add(".....................................####..................."); WillReturn.Add(".....................................#####.................."); WillReturn.Add(".....................................######................."); WillReturn.Add(".....................................######................."); WillReturn.Add(".....................................######................."); WillReturn.Add(".....................................#####.................."); WillReturn.Add("....................................#####..................."); WillReturn.Add("....................................#####..................."); WillReturn.Add("....................................######.................."); WillReturn.Add("...................................#####...................."); WillReturn.Add("................................#.######...................."); WillReturn.Add(".................................#######...................."); WillReturn.Add("............................#...########...................."); WillReturn.Add("............................#.##########...................."); WillReturn.Add("...........................############....................."); WillReturn.Add("...........................############....................."); WillReturn.Add("..........................#############....................."); WillReturn.Add(".........................###############...................."); WillReturn.Add("....................###..##############....................."); WillReturn.Add("...............#####################.##....................."); WillReturn.Add("..............###################.#..#......................"); WillReturn.Add(".....#......###############.####..#........................."); WillReturn.Add("..........########......###................................."); WillReturn.Add("..........####....##.#.#####................................"); WillReturn.Add("......#.##...#.######..###.................................."); WillReturn.Add(".....##.####...######..##..................................."); WillReturn.Add("......######..####.#........................................"); WillReturn.Add("...#...######.###..........................................."); WillReturn.Add("......##.####..#............................................"); WillReturn.Add(".......#.###................................................"); WillReturn.Add("........####................................................"); WillReturn.Add(".......####................................................."); WillReturn.Add(".......####................................................."); WillReturn.Add(".......#.##................................................."); WillReturn.Add("............................................................"); WillReturn.Add("..........#................................................."); WillReturn.Add("........#.#................................................."); WillReturn.Add("............................................................"); WillReturn.Add("............................................................"); WillReturn.Add("............................................................"); //4 } else if (InputPattern == "Input4") { WillReturn.Add("5 5"); WillReturn.Add("#####"); WillReturn.Add("###.#"); WillReturn.Add("#####"); WillReturn.Add("#####"); WillReturn.Add("#####"); //2 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static int UB_X; static int UB_Y; static void Main() { List<string> InputList = GetInputList(); int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray(); int H = wkArr[0]; int W = wkArr[1]; UB_X = W - 1; UB_Y = H - 1; char[,] BanArr = new char[UB_X + 1, UB_Y + 1]; for (int LoopX = 0; LoopX <= UB_X; LoopX++) { for (int LoopY = 0; LoopY <= UB_Y; LoopY++) { BanArr[LoopX, LoopY] = InputList[LoopY + 1][LoopX]; } } //最大の正方形の1辺を求める int MaxSeihoukeiLength = 1; for (int LoopX = 0; LoopX <= UB_X; LoopX++) { if (LoopX + MaxSeihoukeiLength - 1 > UB_X) break; for (int LoopY = 0; LoopY <= UB_Y; LoopY++) { if (LoopY + MaxSeihoukeiLength - 1 > UB_Y) break; if (BanArr[LoopX, LoopY] == '.') continue; int wkSeihoukeiLength = DeriveSeihoukeiLength(BanArr, LoopX, LoopY); //Console.WriteLine("({0},{1})を開始とした最大正方形={2}", LoopX, LoopY, wkSeihoukeiLength); if (MaxSeihoukeiLength < wkSeihoukeiLength) MaxSeihoukeiLength = wkSeihoukeiLength; } } if (MaxSeihoukeiLength % 2 == 0) Console.WriteLine(MaxSeihoukeiLength / 2); else Console.WriteLine(MaxSeihoukeiLength / 2 + 1); } //始点を引数として、正方形の大きさを返す static int DeriveSeihoukeiLength(char[,] pBanArr, int pStaX, int pStaY) { int SeihoukeiLength = 1; while (true) { //UB超えの場合 if (pStaX + SeihoukeiLength - 1 > UB_X) return SeihoukeiLength - 1; if (pStaY + SeihoukeiLength - 1 > UB_Y) return SeihoukeiLength - 1; //横のループ for (int X = pStaX; X <= pStaX + SeihoukeiLength - 1; X++) { if (pBanArr[X, pStaY + SeihoukeiLength - 1] == '.') return SeihoukeiLength - 1; } //縦のループ for (int Y = pStaY; Y <= pStaY + SeihoukeiLength - 1; Y++) { if (pBanArr[pStaX + SeihoukeiLength - 1, Y] == '.') return SeihoukeiLength - 1; } SeihoukeiLength++; } } }