結果

問題 No.179 塗り分け
ユーザー yuki2006yuki2006
提出日時 2015-04-06 02:47:59
言語 Go1.4
(1.4.2)
結果
AC  
実行時間 118 ms / 3,000 ms
コード長 1,398 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 33,308 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 20:38:49
合計ジャッジ時間 4,857 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 118 ms
4,380 KB
testcase_08 AC 66 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 33 ms
4,376 KB
testcase_11 AC 24 ms
4,376 KB
testcase_12 AC 49 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 33 ms
4,380 KB
testcase_19 AC 29 ms
4,384 KB
testcase_20 AC 63 ms
4,376 KB
testcase_21 AC 65 ms
4,380 KB
testcase_22 AC 83 ms
4,380 KB
testcase_23 AC 33 ms
4,380 KB
testcase_24 AC 60 ms
4,380 KB
testcase_25 AC 44 ms
4,376 KB
testcase_26 AC 18 ms
4,376 KB
testcase_27 AC 59 ms
4,380 KB
testcase_28 AC 17 ms
4,380 KB
testcase_29 AC 59 ms
4,380 KB
testcase_30 AC 25 ms
4,380 KB
testcase_31 AC 59 ms
4,384 KB
testcase_32 AC 42 ms
4,380 KB
testcase_33 AC 66 ms
4,376 KB
testcase_34 AC 31 ms
4,380 KB
testcase_35 AC 59 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 4 ms
4,380 KB
testcase_44 AC 10 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var s = bufio.NewScanner(os.Stdin)

func next() string {

	s.Split(bufio.ScanWords)
	s.Scan()
	return s.Text()
}
func nextLine() string {
	s.Split(bufio.ScanLines)
	s.Scan()
	if nil != s.Err() {
		panic(s.Err())
	}
	return s.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}


func solve(S []string, x int, y int) bool {
	if y == 0 && x <= 0 {
		return false
	}
	checked := make([][]bool, H)
	for i := 0; i < len(S); i++ {
		checked[i] = make([]bool, W)
	}
	count := 0
	for j := 0; j < H; j++ {
		for i := 0; i < W; i++ {
			if checked[j][i] || S[j][i] == '.' {
				continue
			}
			if 0 <= i+x && i+x < W && 0 <= j+y && j+y < H {
				if checked[j + y][i + x] {
					return false
				}
				if S[j+y][i+x] == '.' {
					return false
				}

				checked[j][i] = true
				checked[j+y][i+x] = true
				count++

			}else {
				return false
			}
		}
	}
	if count > 0 {
		println(count, x, y)
		return true
	}

	return false
}

var H int
var W int

func main() {

	H = nextInt()
	W = nextInt()


	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = nextLine()
	}



	for i := -W + 1; i < W; i++ {
		for j := 0; j < H; j++ {
			if solve(S, i, j) {
				fmt.Println("YES")
				return
			}
		}
	}

	fmt.Println("NO")



}



0