結果

問題 No.2379 Burnside's Theorem
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-07-21 09:26:16
言語 C#
(.NET 8.0.203)
結果
RE  
実行時間 -
コード長 2,945 bytes
コンパイル時間 13,779 ms
コンパイル使用メモリ 156,956 KB
実行使用メモリ 182,216 KB
最終ジャッジ日時 2023-10-21 10:30:31
合計ジャッジ時間 20,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (106 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
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,l,e;
        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 A = Combination.Generate(a.Count,a.Count/2,false);
        var B = new List<List<int[]>>();
        for(i=0;i<A.Count;i++){
            var k = new List<int[]>();
            for(j=0;j<a.Count;j++){
                if(A[i].All(value => value!=j)){
                    k.Add(a[j]);
                }
            }
            B.Add(k);
        }
        bool c = a.Count%2==0;
        if(!c){
            Console.WriteLine("NO");
        }
        i=0;
        while(c&&i<A.Count){
           for(j=0;j<h;j++){
               for(l=0;l<w;l++){
                   var m = new List<int[]>();
                   foreach(var x in A[i]){
                       var k = new int[2];
                       k[0] = a[x][0] + j;
                       k[1] = a[x][1] + l;
                       m.Add(k);
                   }
                   var z = new bool[m.Count];
                   for(e=0;e<m.Count;e++){
                        z[e] = m[e][0]==B[i][e][0]&&m[e][1]==B[i][e][1];
                   }
                   if(z.All(value=>value)){
                       c = false;
                       Console.WriteLine("YES");
                       break;
                   }
               }
           }
           i++;
        }
        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