結果

問題 No.179 塗り分け
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-07-31 17:29:51
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 244 ms / 3,000 ms
コード長 2,471 bytes
コンパイル時間 7,437 ms
コンパイル使用メモリ 167,216 KB
実行使用メモリ 184,252 KB
最終ジャッジ日時 2024-04-18 17:33:14
合計ジャッジ時間 11,710 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
30,072 KB
testcase_01 AC 50 ms
29,812 KB
testcase_02 AC 48 ms
29,952 KB
testcase_03 AC 51 ms
29,824 KB
testcase_04 AC 52 ms
30,080 KB
testcase_05 AC 47 ms
29,824 KB
testcase_06 AC 62 ms
31,616 KB
testcase_07 AC 48 ms
30,080 KB
testcase_08 AC 53 ms
30,080 KB
testcase_09 AC 51 ms
30,080 KB
testcase_10 AC 67 ms
31,616 KB
testcase_11 AC 66 ms
31,728 KB
testcase_12 AC 244 ms
36,992 KB
testcase_13 AC 52 ms
29,952 KB
testcase_14 AC 51 ms
30,080 KB
testcase_15 AC 50 ms
29,952 KB
testcase_16 AC 49 ms
30,080 KB
testcase_17 AC 49 ms
29,824 KB
testcase_18 AC 62 ms
31,476 KB
testcase_19 AC 63 ms
31,616 KB
testcase_20 AC 51 ms
30,080 KB
testcase_21 AC 53 ms
29,952 KB
testcase_22 AC 65 ms
31,616 KB
testcase_23 AC 66 ms
31,488 KB
testcase_24 AC 64 ms
31,744 KB
testcase_25 AC 64 ms
31,472 KB
testcase_26 AC 65 ms
31,600 KB
testcase_27 AC 65 ms
32,128 KB
testcase_28 AC 64 ms
31,488 KB
testcase_29 AC 67 ms
33,012 KB
testcase_30 AC 63 ms
32,128 KB
testcase_31 AC 66 ms
33,792 KB
testcase_32 AC 64 ms
31,872 KB
testcase_33 AC 73 ms
33,920 KB
testcase_34 AC 64 ms
32,128 KB
testcase_35 AC 73 ms
34,560 KB
testcase_36 AC 48 ms
29,952 KB
testcase_37 AC 51 ms
29,824 KB
testcase_38 AC 50 ms
30,080 KB
testcase_39 AC 51 ms
29,952 KB
testcase_40 AC 50 ms
29,952 KB
testcase_41 AC 49 ms
30,080 KB
testcase_42 AC 52 ms
29,952 KB
testcase_43 AC 60 ms
31,616 KB
testcase_44 AC 61 ms
31,616 KB
testcase_45 AC 51 ms
184,252 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (90 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

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

namespace yukicoder
{
    public class Program
    {
        public static void Main()
        {
            var line = Console.ReadLine().Split(' ');
            var h = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            var s = new string[h];
            var b = new List<int[]>();
            for (var i = 0; i < h; i++)
            {
                s[i] = Console.ReadLine();
                for(var j = 0; j < w; j++)
                {
                    if (s[i][j] == '#')
                    {
                        b.Add(new int[2] { i, j });
                    }
                }
            }
            var n = b.Count;
            if (n % 2 != 0)
            {
                Console.WriteLine("NO");
            }
            else
            {
                var z = true;
                for(var i = 1; i < n; i++)
                {
                    var c = new bool[n];
                    var k = new int[2] { b[i][0] - b[0][0], b[i][1] - b[0][1] };
                    c[0] = true;
                    c[i] = true;
                    for(var j = 1; j < n; j++)
                    {
                        if (!c[j])
                        {
                            c[j] = true;
                            var x = b[j][0] + k[0];
                            var y = b[j][1] + k[1];
                            if (x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '#')
                            {
                                for (var l = 0; l < n; l++)
                                {
                                    if (b[l][0] == x && b[l][1] == y)
                                    {
                                        c[l] = true;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    if (c.All(value => value))
                    {
                        Console.WriteLine("YES");
                        z = false;
                        break;
                    }
                }
                if (z)
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}
0