結果
問題 | No.402 最も海から遠い場所 |
ユーザー | mban |
提出日時 | 2016-09-17 12:48:27 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,716 ms / 3,000 ms |
コード長 | 2,094 bytes |
コンパイル時間 | 5,390 ms |
コンパイル使用メモリ | 107,380 KB |
実行使用メモリ | 200,316 KB |
最終ジャッジ日時 | 2023-08-10 22:18:41 |
合計ジャッジ時間 | 15,198 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
22,008 KB |
testcase_01 | AC | 57 ms
23,896 KB |
testcase_02 | AC | 59 ms
21,992 KB |
testcase_03 | AC | 59 ms
23,932 KB |
testcase_04 | AC | 57 ms
21,980 KB |
testcase_05 | AC | 56 ms
21,932 KB |
testcase_06 | AC | 57 ms
21,980 KB |
testcase_07 | AC | 59 ms
21,936 KB |
testcase_08 | AC | 60 ms
21,972 KB |
testcase_09 | AC | 60 ms
22,044 KB |
testcase_10 | AC | 60 ms
22,096 KB |
testcase_11 | AC | 59 ms
21,884 KB |
testcase_12 | AC | 59 ms
21,940 KB |
testcase_13 | AC | 65 ms
22,656 KB |
testcase_14 | AC | 62 ms
22,168 KB |
testcase_15 | AC | 93 ms
24,272 KB |
testcase_16 | AC | 106 ms
26,788 KB |
testcase_17 | AC | 714 ms
99,940 KB |
testcase_18 | AC | 1,716 ms
69,180 KB |
testcase_19 | AC | 1,278 ms
200,316 KB |
testcase_20 | AC | 1,315 ms
63,340 KB |
testcase_21 | AC | 1,261 ms
161,264 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Collections; using System.Collections.Generic; using System.Linq; class Program { static int H, W; static int[,] S; static int[] tate = { -1, 0, 1, -1, 1, -1, 0, 1 }, yoko = { -1, -1, -1, 0, 0, 1, 1, 1 }; static void Main() { int[] q = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); H = q[0]; W = q[1]; Queue<XY> Q = new Queue<XY>(); S = new int[H + 2, W + 2]; for (int i = 0; i < W + 2; i++) { S[0, i] = 0; Q.Enqueue(new XY(0, i)); S[H + 1, i] = 0; Q.Enqueue(new XY(H + 1, i)); } for (int i = 0; i < H; i++) { string qw = Console.ReadLine(); for (int j = 0; j < W + 2; j++) { if (j == 0 || j == W + 1 || qw[j - 1] == '.') { S[i + 1, j] = 0; Q.Enqueue(new XY(i + 1, j)); } else { S[i + 1, j] = -1; } } } while (Q.Count > 0) { XY xy = Q.Dequeue(); for(int i = 0; i < 8; i++) { if (tate[i] + xy.Y >= 0 && tate[i] + xy.Y <= H + 1 && yoko[i] + xy.X >= 0 && yoko[i]+xy.X <= W + 1) { if (S[tate[i] + xy.Y, yoko[i] + xy.X] == -1) { S[tate[i] + xy.Y, yoko[i] + xy.X] = S[xy.Y, xy.X] + 1; Q.Enqueue(new XY(tate[i] + xy.Y, yoko[i] + xy.X)); } } } } int max = int.MinValue; for(int i= 1;i<= H; i++) { for(int j = 1; j <= W; j++) { max = Math.Max(max, S[i, j]); } } Console.WriteLine(max); } } public struct XY { public XY(int y,int x) { this.X = x; this.Y = y; } public int Y { get; set; } public int X { get; set; } }