結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2016-11-09 17:24:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 165 ms / 3,000 ms |
| コード長 | 2,197 bytes |
| コンパイル時間 | 1,041 ms |
| コンパイル使用メモリ | 113,124 KB |
| 実行使用メモリ | 47,616 KB |
| 最終ジャッジ日時 | 2024-07-23 14:39:57 |
| 合計ジャッジ時間 | 4,254 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
class Magatro
{
static int H, W;
static string[] S;
static void Main()
{
Read();
for(int x = -W; x <= W; x++)
{
for(int y = 0; y <= H; y++)
{
if (x == 0 && y == 0)
{
continue;
}
if (s(x, y))
{
Console.WriteLine("YES");
return;
}
}
}
Console.WriteLine("NO");
}
static bool s(int x,int y)
{
int[,] ban = new int[H, W];
for(int i = 0; i < H; i++)
{
for(int j = 0; j < W; j++)
{
if (S[i][j] == '#')
{
if (ban[i, j] == 0)
{
ban[i, j] = 1;
int bly = i + y;
int blx = j + x;
if (blx < W && blx >= 0 && bly < H && bly >= 0)
{
if (S[bly][blx] != '#')
{
return false;
}
ban[bly, blx] = 2;
}
else
{
return false;
}
}
}
}
}
bool a = false;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
if (S[i][j] == '#' )
{
a = true;
if( ban[i, j] == 0)
return false;
}
}
}
return a;
}
static void Read()
{
string[] s = Console.ReadLine().Split(' ');
H = int.Parse(s[0]);
W = int.Parse(s[1]);
S = new string[H];
for(int i = 0; i < H; i++)
{
S[i] = Console.ReadLine();
}
}
}
mban