結果

問題 No.179 塗り分け
ユーザー RaffRaff
提出日時 2022-03-07 16:52:15
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,604 bytes
コンパイル時間 11,024 ms
コンパイル使用メモリ 209,392 KB
実行使用メモリ 8,128 KB
最終ジャッジ日時 2023-09-29 17:52:28
合計ジャッジ時間 13,280 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,388 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 20 ms
8,124 KB
testcase_08 AC 11 ms
8,128 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 11 ms
6,420 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 9 ms
8,124 KB
testcase_21 AC 12 ms
8,116 KB
testcase_22 AC 15 ms
8,124 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 11 ms
8,120 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 WA -
testcase_27 AC 10 ms
8,124 KB
testcase_28 WA -
testcase_29 AC 10 ms
8,116 KB
testcase_30 WA -
testcase_31 AC 11 ms
8,124 KB
testcase_32 AC 3 ms
4,432 KB
testcase_33 AC 11 ms
8,124 KB
testcase_34 WA -
testcase_35 AC 11 ms
8,120 KB
testcase_36 AC 2 ms
4,384 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,384 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func print(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func slice_conv(x []int, sep string) string {
	ret := make([]string, len(x))
	for i, v := range x {
		ret[i] = strconv.Itoa(v)
	}
	return strings.Trim(strings.Join(ret, sep), "[]")
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func chmax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func chmin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

type Pair struct {
	f, s int
}

var (
	H, W int
	S    []string
)

func solve(dy, dx int) bool {
	used := make([][]bool, H)
	for i := range used {
		used[i] = make([]bool, W)
	}
	ok := false
	for i := range S {
		for j := range S[i] {
			if S[i][j] == '#' && !used[i][j] {
				if i+dy >= H || j+dx >= W {
					return false
				}
				if S[i+dy][j+dx] == '#' && !used[i+dy][j+dx] {
					used[i+dy][j+dx] = true
				} else {
					return false
				}
				ok = true
			}
		}
	}
	return ok
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)

	H, W = nextInt(), nextInt()

	S = make([]string, H)
	for i := range S {
		S[i] = nextString()
	}

	for i := range S {
		for j := range S[i] {
			if i == 0 && j == 0 {
				continue
			}
			if solve(i, j) {
				print("YES")
				return
			}
		}
	}
	print("NO")
}
0