結果

問題 No.402 最も海から遠い場所
ユーザー yozayoza
提出日時 2016-07-23 00:39:42
言語 Go
(1.22.1)
結果
AC  
実行時間 137 ms / 3,000 ms
コード長 766 bytes
コンパイル時間 10,360 ms
コンパイル使用メモリ 229,620 KB
実行使用メモリ 83,968 KB
最終ジャッジ日時 2024-04-24 05:50:20
合計ジャッジ時間 11,981 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 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 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 AC 76 ms
42,368 KB
testcase_18 AC 137 ms
83,968 KB
testcase_19 AC 25 ms
12,032 KB
testcase_20 AC 134 ms
83,968 KB
testcase_21 AC 121 ms
83,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

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
	sc := bufio.NewScanner(os.Stdin)
	for y := 1; y <= h; y++ {
		sc.Scan()
		row := sc.Text()
		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