結果

問題 No.179 塗り分け
ユーザー 14番14番
提出日時 2016-03-29 23:26:38
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,988 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 114,884 KB
実行使用メモリ 50,840 KB
最終ジャッジ日時 2024-04-14 06:02:21
合計ジャッジ時間 9,541 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,108 KB
testcase_01 AC 26 ms
23,984 KB
testcase_02 AC 25 ms
25,904 KB
testcase_03 AC 25 ms
24,116 KB
testcase_04 AC 25 ms
25,900 KB
testcase_05 AC 56 ms
26,024 KB
testcase_06 AC 26 ms
26,032 KB
testcase_07 WA -
testcase_08 AC 340 ms
45,076 KB
testcase_09 WA -
testcase_10 AC 26 ms
24,244 KB
testcase_11 AC 26 ms
24,236 KB
testcase_12 AC 321 ms
50,840 KB
testcase_13 AC 26 ms
23,980 KB
testcase_14 AC 26 ms
24,068 KB
testcase_15 AC 25 ms
23,980 KB
testcase_16 AC 26 ms
24,200 KB
testcase_17 AC 25 ms
24,064 KB
testcase_18 AC 33 ms
26,004 KB
testcase_19 AC 34 ms
26,120 KB
testcase_20 AC 325 ms
47,936 KB
testcase_21 AC 380 ms
43,292 KB
testcase_22 AC 443 ms
49,292 KB
testcase_23 AC 26 ms
24,200 KB
testcase_24 AC 354 ms
45,200 KB
testcase_25 AC 28 ms
23,960 KB
testcase_26 WA -
testcase_27 AC 346 ms
47,380 KB
testcase_28 WA -
testcase_29 AC 344 ms
43,152 KB
testcase_30 WA -
testcase_31 AC 351 ms
47,124 KB
testcase_32 AC 111 ms
31,364 KB
testcase_33 AC 349 ms
45,336 KB
testcase_34 WA -
testcase_35 AC 351 ms
45,068 KB
testcase_36 AC 25 ms
24,196 KB
testcase_37 AC 26 ms
23,988 KB
testcase_38 AC 26 ms
26,364 KB
testcase_39 AC 26 ms
23,980 KB
testcase_40 AC 26 ms
23,816 KB
testcase_41 AC 26 ms
24,068 KB
testcase_42 AC 26 ms
25,984 KB
testcase_43 AC 30 ms
23,808 KB
testcase_44 AC 61 ms
28,072 KB
testcase_45 AC 27 ms
24,196 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Text;

public class Program
{
    public void Proc(){
        Reader.IsDebug = false;
        int[] inpt = Reader.GetInt();
        int wLen = inpt[1];
        int hLen = inpt[0];
        this.Map = new BlockState[hLen, wLen];
        for(int i=0; i<hLen; i++) {
            string str = Reader.ReadLine();
            for(int j=0;j<str.Length; j++) {
                if(str[j] == '#') {
                    this.Map[i,j] = BlockState.black;
                } else
                {
                    this.Map[i,j] = BlockState.white;
                }
            }
        }
        for(int i=0; i<hLen; i++) {
            for(int j=0; j<wLen; j++) {
                if(CanPaint(j,i)) {
                    Console.WriteLine("YES");
                    return;
                }
            }
        }
        Console.WriteLine("NO");
    }
    
    private bool CanPaint(int x, int y) {
        if(x == 0 && y == 0) {
            return false;
        }
        BlockState[,] map = CopyMap();
        for(int i=0; i<map.GetLength(0); i++) {
            for(int j=0; j<map.GetLength(1); j++) {
                if(map[i,j]==BlockState.black) {
                    int px = j+x;
                    int py = i+y;
                    if(px >= 0 && px < map.GetLength(1) && py>=0 && py < map.GetLength(0) && map[py, px] == BlockState.black) {
                        map[i,j] = BlockState.blue;
                        map[py, px] = BlockState.read;
                    } else
                    {
                         return false;
                    }
                }
            }
        }
        return true;
    }
    private BlockState[,] Map;
    
    private BlockState[,] CopyMap() {
        BlockState[,] newMap = new BlockState[this.Map.GetLength(0), this.Map.GetLength(1)];
        for(int i=0; i<this.Map.GetLength(0); i++) {
            for(int j=0; j<this.Map.GetLength(1); j++) {
                newMap[i,j] = Map[i,j];
            }
        }
        return newMap;
    }
    
    enum BlockState {
        white,
        black,
        read,
        blue
    }
    
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

class Reader
{
    public static bool IsDebug = true;
    
    private static System.IO.StringReader sr;
    
    public static string ReadLine() {
        if(IsDebug) {
            if(sr == null) {
                sr = new System.IO.StringReader(initStr.Trim());
            }
            return sr.ReadLine();
        } else {
            return Console.ReadLine();
        }
    }
    
    public static int[] GetInt(char delimiter = ' ') {
        string[] inpt = ReadLine().Split(delimiter);
        int[] ret = new int[inpt.Length];
        for(int i=0; i<inpt.Length; i++) {
            ret[i] = int.Parse(inpt[i]);
        }
        return ret;
    }
    
    private static string initStr = @"




    ";
}

0