結果

問題 No.402 最も海から遠い場所
ユーザー yozayoza
提出日時 2016-07-23 00:32:21
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 727 bytes
コンパイル時間 11,840 ms
コンパイル使用メモリ 235,748 KB
実行使用メモリ 60,928 KB
最終ジャッジ日時 2024-04-24 05:26:53
合計ジャッジ時間 17,616 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 44 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 233 ms
5,376 KB
testcase_16 AC 317 ms
5,376 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)

	dp := [][]int{}
	for i := 0; i <= h; i++ {
		dp = append(dp, make([]int, w+1))
	}

	max := 0
	for y := 1; y <= h; y++ {
		var row string
		fmt.Scanf("%s", &row)
		for x := 1; x <= w; x++ {
			if row[x-1:x] == "." {
				continue
			}
			dp[y][x] = minInt(dp[y-1][x-1], dp[y-1][x], dp[y][x-1]) + 1
			max = maxInt(max, dp[y][x])
		}
	}
	fmt.Println((max + 1) / 2)
}

func maxInt(list ...int) int {
	max := int(math.MinInt64)
	for _, i := range list {
		if i > max {
			max = i
		}
	}
	return max
}

func minInt(list ...int) int {
	min := int(math.MaxInt64)
	for _, i := range list {
		if i < min {
			min = i
		}
	}
	return min
}
0