結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-31 16:37:20 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,602 bytes |
| 記録 | |
| コンパイル時間 | 11,469 ms |
| コンパイル使用メモリ | 170,776 KB |
| 実行使用メモリ | 113,256 KB |
| 最終ジャッジ日時 | 2024-10-10 09:57:13 |
| 合計ジャッジ時間 | 17,953 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 2 TLE * 1 |
| other | -- * 40 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (105 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;
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);
}
}
}
}
}