結果
問題 |
No.2379 Burnside's Theorem
|
ユーザー |
|
提出日時 | 2023-07-21 09:26:16 |
言語 | C# (.NET 8.0.404) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,945 bytes |
コンパイル時間 | 11,449 ms |
コンパイル使用メモリ | 165,412 KB |
実行使用メモリ | 193,820 KB |
最終ジャッジ日時 | 2024-09-21 11:36:58 |
合計ジャッジ時間 | 20,088 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 4 |
other | RE * 20 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (98 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/
ソースコード
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); } } } }