結果

問題 No.179 塗り分け
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-07-31 16:37:20
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 3,602 bytes
コンパイル時間 7,747 ms
コンパイル使用メモリ 165,968 KB
実行使用メモリ 113,120 KB
最終ジャッジ日時 2024-04-18 16:40:03
合計ジャッジ時間 16,943 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
33,792 KB
testcase_01 WA -
testcase_02 AC 754 ms
70,320 KB
testcase_03 WA -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (107 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 a = new List<int[]>();
            int i, j;
            for (i = 0; i < h; i++)
            {
                s[i] = Console.ReadLine();
                for (j = 0; j < w; j++)
                {
                    if (s[i][j] == '#')
                    {
                        var k = new int[2];
                        k[0] = i;
                        k[1] = j;
                        a.Add(k);
                    }
                }
            }
            var t = a.Count;
            var aa = Combination.Generate(t, t / 2, false);
            var A = new List<List<int[]>>();
            var B = new List<List<int[]>>();
            foreach(var x in aa)
            {
                var k = new List<int[]>();
                var l = new List<int[]>();
                for (i = 0; i < t; i++)
                {
                    if (x.Any(value => value == i))
                    {
                        k.Add(a[i]);
                    }
                    else
                    {
                        l.Add(a[i]);
                    }
                }
                A.Add(k);
                B.Add(k);
            }
            bool c = t % 2 == 0;
            if (!c)
            {
                Console.WriteLine("NO");
            }
            for (i = 0; i < A[i].Count; i++)
            {
                var k = A[i].Select(x => new int[2] { x[0] - A[i][0][0], x[1] - A[i][0][1] }).ToArray();
                var l = B[i].Select(x => new int[2] { x[0] - B[i][0][0], x[1] - B[i][0][1] }).ToArray();
                var p = true;
                for (j = 0; j < k.Count(); j++)
                {
                    if (!(k[j][0] == l[j][0] && k[j][1] == l[j][1]))
                    {
                        p = false;
                        break;
                    }
                }
                if (p)
                {
                    c = false;
                    Console.WriteLine("YES");
                    break;
                }
            }
            if (c)
            {
                Console.WriteLine("NO");
            }
        }
        static class Combination
        {
            private static List<List<int>> _comb;
            public static List<List<int>> Generate(int n, int r, bool dupulication)
            {
                _comb = new List<List<int>>();
                CalcCombination(new List<int>(), n, r, dupulication);
                return _comb;
            }
            private static void CalcCombination(List<int> list, int n, int r, bool dupulication)
            {
                if (list.Count == r)
                {
                    _comb.Add(new List<int>(list));
                    return;
                }
                var index = 0;
                if (dupulication)
                {
                    index = list.Any() ? list.Last() : 0;
                }
                else
                {
                    index = list.Any() ? list.Last() + 1 : 0;
                }
                for (int i = index; i < n; i++)
                {
                    list.Add(i);
                    CalcCombination(list, n, r, dupulication);
                    list.Remove(i);
                }
            }
        }
    }
}
0