結果
問題 | No.179 塗り分け |
ユーザー | 14番 |
提出日時 | 2016-03-29 23:32:18 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,214 ms / 3,000 ms |
コード長 | 3,079 bytes |
コンパイル時間 | 3,350 ms |
コンパイル使用メモリ | 107,360 KB |
実行使用メモリ | 44,664 KB |
最終ジャッジ日時 | 2023-09-30 20:48:48 |
合計ジャッジ時間 | 17,499 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
18,672 KB |
testcase_01 | AC | 59 ms
22,704 KB |
testcase_02 | AC | 58 ms
18,708 KB |
testcase_03 | AC | 57 ms
22,748 KB |
testcase_04 | AC | 58 ms
20,908 KB |
testcase_05 | AC | 118 ms
26,792 KB |
testcase_06 | AC | 59 ms
20,780 KB |
testcase_07 | AC | 1,214 ms
42,516 KB |
testcase_08 | AC | 678 ms
42,616 KB |
testcase_09 | AC | 684 ms
42,560 KB |
testcase_10 | AC | 65 ms
20,660 KB |
testcase_11 | AC | 66 ms
22,776 KB |
testcase_12 | AC | 601 ms
44,144 KB |
testcase_13 | AC | 58 ms
23,020 KB |
testcase_14 | AC | 57 ms
20,700 KB |
testcase_15 | AC | 58 ms
20,704 KB |
testcase_16 | AC | 58 ms
20,848 KB |
testcase_17 | AC | 58 ms
22,748 KB |
testcase_18 | AC | 77 ms
21,980 KB |
testcase_19 | AC | 77 ms
21,824 KB |
testcase_20 | AC | 637 ms
43,364 KB |
testcase_21 | AC | 753 ms
44,664 KB |
testcase_22 | AC | 911 ms
42,532 KB |
testcase_23 | AC | 66 ms
20,700 KB |
testcase_24 | AC | 693 ms
44,488 KB |
testcase_25 | AC | 68 ms
21,076 KB |
testcase_26 | AC | 155 ms
30,828 KB |
testcase_27 | AC | 682 ms
42,564 KB |
testcase_28 | AC | 88 ms
25,032 KB |
testcase_29 | AC | 686 ms
42,556 KB |
testcase_30 | AC | 320 ms
40,192 KB |
testcase_31 | AC | 685 ms
42,644 KB |
testcase_32 | AC | 231 ms
38,412 KB |
testcase_33 | AC | 681 ms
42,656 KB |
testcase_34 | AC | 177 ms
31,816 KB |
testcase_35 | AC | 747 ms
44,604 KB |
testcase_36 | AC | 58 ms
20,788 KB |
testcase_37 | AC | 57 ms
20,772 KB |
testcase_38 | AC | 57 ms
20,792 KB |
testcase_39 | AC | 57 ms
20,724 KB |
testcase_40 | AC | 57 ms
20,744 KB |
testcase_41 | AC | 58 ms
20,724 KB |
testcase_42 | AC | 59 ms
20,708 KB |
testcase_43 | AC | 67 ms
22,636 KB |
testcase_44 | AC | 124 ms
26,976 KB |
testcase_45 | AC | 60 ms
20,772 KB |
コンパイルメッセージ
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.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=(wLen -1)*-1; 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; } bool isPainted = 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; isPainted = true; } else { return false; } } } } return isPainted; } 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 = @" "; }