結果

問題 No.179 塗り分け
ユーザー skewesskewes
提出日時 2015-12-29 12:33:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 3,000 ms
コード長 2,317 bytes
コンパイル時間 3,332 ms
コンパイル使用メモリ 106,648 KB
実行使用メモリ 26,904 KB
最終ジャッジ日時 2023-09-30 20:45:33
合計ジャッジ時間 6,235 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,636 KB
testcase_01 AC 54 ms
20,812 KB
testcase_02 AC 55 ms
20,644 KB
testcase_03 AC 55 ms
20,600 KB
testcase_04 AC 54 ms
20,648 KB
testcase_05 AC 55 ms
20,660 KB
testcase_06 AC 55 ms
20,636 KB
testcase_07 AC 56 ms
20,824 KB
testcase_08 AC 56 ms
20,900 KB
testcase_09 AC 55 ms
20,652 KB
testcase_10 AC 57 ms
22,740 KB
testcase_11 AC 56 ms
22,788 KB
testcase_12 AC 60 ms
26,904 KB
testcase_13 AC 54 ms
20,748 KB
testcase_14 AC 54 ms
18,644 KB
testcase_15 AC 54 ms
20,696 KB
testcase_16 AC 55 ms
22,800 KB
testcase_17 AC 55 ms
22,788 KB
testcase_18 AC 57 ms
22,804 KB
testcase_19 AC 56 ms
18,692 KB
testcase_20 AC 58 ms
22,784 KB
testcase_21 AC 56 ms
20,776 KB
testcase_22 AC 56 ms
20,700 KB
testcase_23 AC 56 ms
20,596 KB
testcase_24 AC 56 ms
20,664 KB
testcase_25 AC 56 ms
22,756 KB
testcase_26 AC 56 ms
22,700 KB
testcase_27 AC 57 ms
24,748 KB
testcase_28 AC 56 ms
20,700 KB
testcase_29 AC 58 ms
24,884 KB
testcase_30 AC 57 ms
20,864 KB
testcase_31 AC 59 ms
22,716 KB
testcase_32 AC 57 ms
22,840 KB
testcase_33 AC 59 ms
22,708 KB
testcase_34 AC 57 ms
20,872 KB
testcase_35 AC 59 ms
26,900 KB
testcase_36 AC 55 ms
18,692 KB
testcase_37 AC 55 ms
20,728 KB
testcase_38 AC 55 ms
22,740 KB
testcase_39 AC 55 ms
20,876 KB
testcase_40 AC 56 ms
20,788 KB
testcase_41 AC 55 ms
20,780 KB
testcase_42 AC 55 ms
22,752 KB
testcase_43 AC 58 ms
22,892 KB
testcase_44 AC 57 ms
22,676 KB
testcase_45 AC 54 ms
20,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class _179
    {
        static void Main()
        {
            int[] hw = Array.ConvertAll(Console.ReadLine().Split(' ')
               , x => int.Parse(x));
            int h = hw[0];
            int w = hw[1];
            bool[,] b = new bool[h, w];
            for (int i = 0; i < h; i++)
            {
                string iw = Console.ReadLine();

                for (int j = 0; j < w; j++)
                {
                    char ij = iw[j];

                    b[i, j] = ij == '#';
                }
            }

            int i0 = -1;
            int j0 = -1;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if(b[i,j])
                    {
                        if (i0 == -1 && j0 == -1)
                        {
                            i0 = i;
                            j0 = j;
                        }
                        else
                        {
                            int hd = i - i0;
                            int wd = j - j0;

                            if (isp(h, w, (bool[,])b.Clone(), hd, wd))
                            {
                                Console.WriteLine("YES");
                                return;
                            }
                        }
                    }
                }
            }

            Console.WriteLine("NO");
        }

        static bool isp(int h, int w, bool[,] b, int hd, int wd)
        {
            for (int id = 0; id < h; id++)
            {
                for (int jd = 0; jd < w; jd++)
                {
                    if (b[id, jd])
                    {
                        if (id + hd < 0 || jd + wd < 0
                            || id + hd > h - 1 || jd + wd > w - 1)
                        {
                            return false;
                        }
                        if (b[id + hd, jd + wd])
                        {
                            b[id + hd, jd + wd] = false;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
            return true;
        }
    }
}
0