結果

問題 No.179 塗り分け
ユーザー mbanmban
提出日時 2016-11-09 17:24:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 195 ms / 3,000 ms
コード長 2,197 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 106,132 KB
実行使用メモリ 46,216 KB
最終ジャッジ日時 2023-09-30 20:51:59
合計ジャッジ時間 7,091 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,824 KB
testcase_01 AC 55 ms
20,832 KB
testcase_02 AC 55 ms
22,692 KB
testcase_03 AC 55 ms
22,736 KB
testcase_04 AC 55 ms
20,788 KB
testcase_05 AC 58 ms
28,932 KB
testcase_06 AC 55 ms
20,800 KB
testcase_07 AC 195 ms
42,588 KB
testcase_08 AC 103 ms
42,544 KB
testcase_09 AC 57 ms
23,380 KB
testcase_10 AC 80 ms
44,348 KB
testcase_11 AC 78 ms
44,036 KB
testcase_12 AC 102 ms
46,216 KB
testcase_13 AC 54 ms
18,764 KB
testcase_14 AC 54 ms
20,848 KB
testcase_15 AC 54 ms
20,704 KB
testcase_16 AC 55 ms
18,664 KB
testcase_17 AC 55 ms
22,728 KB
testcase_18 AC 81 ms
40,296 KB
testcase_19 AC 79 ms
43,176 KB
testcase_20 AC 103 ms
43,364 KB
testcase_21 AC 111 ms
44,560 KB
testcase_22 AC 124 ms
44,516 KB
testcase_23 AC 81 ms
42,452 KB
testcase_24 AC 105 ms
42,504 KB
testcase_25 AC 92 ms
42,504 KB
testcase_26 AC 71 ms
38,836 KB
testcase_27 AC 104 ms
42,660 KB
testcase_28 AC 69 ms
37,496 KB
testcase_29 AC 105 ms
42,600 KB
testcase_30 AC 75 ms
44,296 KB
testcase_31 AC 105 ms
44,648 KB
testcase_32 AC 90 ms
44,632 KB
testcase_33 AC 105 ms
44,600 KB
testcase_34 AC 82 ms
42,300 KB
testcase_35 AC 104 ms
42,604 KB
testcase_36 AC 54 ms
22,848 KB
testcase_37 AC 54 ms
20,808 KB
testcase_38 AC 54 ms
20,796 KB
testcase_39 AC 55 ms
20,812 KB
testcase_40 AC 55 ms
22,772 KB
testcase_41 AC 55 ms
20,760 KB
testcase_42 AC 55 ms
20,724 KB
testcase_43 AC 55 ms
20,660 KB
testcase_44 AC 57 ms
24,860 KB
testcase_45 AC 56 ms
20,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Magatro
{
    static int H, W;
    static string[] S;
    static void Main()
    {
        Read();
        
       for(int x = -W; x <= W; x++)
        {
            for(int y = 0; y <= H; y++)
            {
                if (x == 0 && y == 0)
                {
                    continue;
                }
                if (s(x, y))
                {
                    Console.WriteLine("YES");
                    return;
                }
                
            }
        }
        Console.WriteLine("NO");
    }
    static bool s(int x,int y)
    {
        int[,] ban = new int[H, W];
        for(int i = 0; i < H; i++)
        {
            for(int j = 0; j < W; j++)
            {
                if (S[i][j] == '#')
                {
                    if (ban[i, j] == 0)
                    {
                        ban[i, j] = 1;
                        int bly = i + y;
                        int blx = j + x;
                      
                        if (blx < W && blx >= 0 && bly < H && bly >= 0)
                        {
                            if (S[bly][blx] != '#')
                            {
                                return false;
                            }
                            ban[bly, blx] = 2;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
        }
        bool a = false;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (S[i][j] == '#' )
                {
                    a = true;
                    if( ban[i, j] == 0)
                    return false;
                }
               
            }
        }
                return a;
    }
    static void Read()
    {

        string[] s = Console.ReadLine().Split(' ');
        H = int.Parse(s[0]);
        W = int.Parse(s[1]);
        S = new string[H];
        for(int i = 0; i < H; i++)
        {
            S[i] = Console.ReadLine();
        }
    }
   
}
0