結果

問題 No.179 塗り分け
ユーザー suzusuzu
提出日時 2023-05-23 12:14:09
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,777 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 106,308 KB
実行使用メモリ 23,992 KB
最終ジャッジ日時 2023-08-24 16:48:03
合計ジャッジ時間 7,725 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,728 KB
testcase_01 AC 61 ms
21,836 KB
testcase_02 AC 62 ms
21,820 KB
testcase_03 AC 62 ms
23,832 KB
testcase_04 AC 61 ms
21,824 KB
testcase_05 AC 62 ms
21,840 KB
testcase_06 AC 62 ms
21,888 KB
testcase_07 WA -
testcase_08 AC 66 ms
22,012 KB
testcase_09 WA -
testcase_10 AC 63 ms
21,812 KB
testcase_11 AC 63 ms
23,988 KB
testcase_12 AC 67 ms
23,992 KB
testcase_13 AC 62 ms
19,840 KB
testcase_14 AC 62 ms
23,760 KB
testcase_15 AC 62 ms
21,884 KB
testcase_16 AC 62 ms
23,808 KB
testcase_17 WA -
testcase_18 AC 63 ms
23,928 KB
testcase_19 AC 63 ms
23,840 KB
testcase_20 AC 63 ms
21,904 KB
testcase_21 AC 63 ms
21,820 KB
testcase_22 AC 75 ms
21,952 KB
testcase_23 AC 63 ms
21,904 KB
testcase_24 AC 66 ms
22,020 KB
testcase_25 AC 63 ms
23,776 KB
testcase_26 WA -
testcase_27 AC 66 ms
23,848 KB
testcase_28 WA -
testcase_29 AC 66 ms
21,956 KB
testcase_30 WA -
testcase_31 AC 67 ms
21,820 KB
testcase_32 AC 63 ms
19,768 KB
testcase_33 AC 66 ms
19,748 KB
testcase_34 WA -
testcase_35 AC 66 ms
23,836 KB
testcase_36 AC 62 ms
23,892 KB
testcase_37 AC 61 ms
21,840 KB
testcase_38 AC 62 ms
23,860 KB
testcase_39 AC 62 ms
21,760 KB
testcase_40 AC 61 ms
21,956 KB
testcase_41 AC 61 ms
21,812 KB
testcase_42 AC 62 ms
21,748 KB
testcase_43 AC 61 ms
19,956 KB
testcase_44 AC 62 ms
21,912 KB
testcase_45 AC 62 ms
21,876 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.Linq;
using System.Collections.Generic;

namespace yukicoder
{
	enum Colors
	{
		Black,
		White,
		Red,
		Blue
	}
	
	class pg
	{
		static void Main(string[] args)
		{
			var line1 = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
			int H = line1[0];
			int W = line1[1];
		
			var defaultColors = new Colors[H,W];
			var paintColors = new Colors[H,W];
		
			int bnum = 0;//黒の数
		
			for(int ih = 0;ih < H;ih++)
			{
				var line2 = Console.ReadLine().Select(c => c.ToString()).ToArray();
				for(int iw = 0;iw < W;iw++)
				{
					if(line2[iw] == "#")
					{
						defaultColors[ih,iw] = Colors.Black;
						bnum++;
					}else
					{	
						defaultColors[ih,iw] = Colors.White;
					}
					
				}
			}	
		
			Array.Copy(defaultColors,paintColors,defaultColors.Length);
		
		
			if(bnum % 2 == 1)//黒の数が奇数だったらnoを出力
			{
				Console.WriteLine("NO");
				return;
			}
			
			for(int gapH = 0;gapH < H;gapH++)//ずれ
			{
				for(int gapW = 0;gapW < W;gapW++)//ずれ
				{
					for(int ih = 0;ih < H;ih++)//paint更新
					{
						for(int iw = 0;iw < W;iw++)//paint更新
						{
							if(paintColors[ih,iw] == Colors.Black)
							{
								paintColors[ih,iw] = Colors.Red;
								
								if(ih + gapH >= H || iw + gapW >= W || paintColors[ih + gapH,iw + gapW] != Colors.Black)//配列を逸脱するか、塗り替え先が黒でないとき失敗
								{
									goto PaintEnd;
								}
								
								paintColors[ih + gapH,iw + gapW] = Colors.Blue;
							}
						}
					}
					Console.WriteLine("YES");//最後まで塗り替えられた
					return;
					
					PaintEnd:
					Array.Copy(defaultColors,paintColors,defaultColors.Length);
				}
			}
			Console.WriteLine("NO");
		}
	}
}	
0