結果

問題 No.179 塗り分け
ユーザー AreTrashAreTrash
提出日時 2016-10-12 23:36:52
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,665 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 111,812 KB
実行使用メモリ 30,692 KB
最終ジャッジ日時 2024-04-14 06:11:21
合計ジャッジ時間 3,709 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
26,196 KB
testcase_01 AC 26 ms
24,068 KB
testcase_02 AC 26 ms
24,188 KB
testcase_03 AC 26 ms
24,372 KB
testcase_04 AC 26 ms
24,280 KB
testcase_05 AC 26 ms
24,196 KB
testcase_06 AC 25 ms
24,064 KB
testcase_07 WA -
testcase_08 AC 30 ms
30,428 KB
testcase_09 WA -
testcase_10 AC 26 ms
26,452 KB
testcase_11 AC 26 ms
24,196 KB
testcase_12 AC 29 ms
30,560 KB
testcase_13 AC 26 ms
22,196 KB
testcase_14 AC 25 ms
26,196 KB
testcase_15 AC 27 ms
26,324 KB
testcase_16 AC 27 ms
24,068 KB
testcase_17 WA -
testcase_18 AC 26 ms
24,188 KB
testcase_19 AC 27 ms
24,200 KB
testcase_20 AC 29 ms
30,440 KB
testcase_21 AC 31 ms
28,272 KB
testcase_22 AC 36 ms
28,272 KB
testcase_23 AC 27 ms
24,196 KB
testcase_24 AC 29 ms
30,184 KB
testcase_25 AC 25 ms
24,148 KB
testcase_26 WA -
testcase_27 AC 28 ms
30,436 KB
testcase_28 WA -
testcase_29 AC 29 ms
30,180 KB
testcase_30 WA -
testcase_31 AC 29 ms
30,436 KB
testcase_32 AC 27 ms
26,192 KB
testcase_33 AC 28 ms
26,484 KB
testcase_34 WA -
testcase_35 AC 28 ms
28,396 KB
testcase_36 AC 26 ms
26,492 KB
testcase_37 AC 26 ms
26,068 KB
testcase_38 AC 26 ms
24,064 KB
testcase_39 AC 25 ms
24,152 KB
testcase_40 AC 26 ms
24,236 KB
testcase_41 AC 27 ms
26,196 KB
testcase_42 AC 26 ms
24,160 KB
testcase_43 AC 27 ms
26,240 KB
testcase_44 AC 25 ms
24,016 KB
testcase_45 AC 26 ms
24,364 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace No179{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var H = sr.Next<int>();
            var W = sr.Next<int>();
            var S = sr.Next<string>(H);

            Func<int, int, bool> isInside = (x, y) => 0 <= x && x < W && 0 <= y && y < H;
            for(var y = 0; y < H; y++){
                for(var x = 0; x < W; x++){
                    var g = new bool[H, W];
                    for(var i = 0; i < H; i++){
                        for(var j = 0; j < W; j++){
                            if(!g[i, j] && S[i][j] == '#'){
                                g[i, j] = true;
                                if(isInside(j + x, i + y) && S[i + y][j + x] == '#' && !g[i + y, j + x]){
                                    g[i + y, j + x] = true;
                                } else{
                                    goto Next;
                                } 
                            }
                        }
                    }
                    Console.WriteLine("YES");
                    return;
                    Next:;
                }
            }
            Console.WriteLine("NO");
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}
0