結果

問題 No.179 塗り分け
ユーザー kuuso1
提出日時 2015-04-05 23:57:48
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 3,000 ms
コード長 1,600 bytes
コンパイル時間 3,329 ms
コンパイル使用メモリ 112,072 KB
実行使用メモリ 32,184 KB
最終ジャッジ日時 2024-07-23 14:25:12
合計ジャッジ時間 5,514 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.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		found=false;
		int i0=-1;int j0=-1;
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++){
				if(S[i][j]=='.')continue;
				if(i0==-1){
					i0=i;j0=j;
					continue;
				}
				if(!found){
					check(i-i0,j-j0);
				}
			}
		}
		Console.WriteLine(found?"YES":"NO");
	}
	
	void check(int offi,int offj){
		if(found)return;
		bool[,] brd=new bool[N,M];
		bool chk=true;
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++){
				if(S[i][j]=='.')continue;
				if(brd[i,j]==true)continue;
				if(i+offi<N && i+offi>=0 && j+offj<M && j+offj>=0){
					brd[i,j]=true;
					if(S[i+offi][j+offj]=='.')return;
					brd[i+offi,j+offj]=true;
				}else{
					return;
				}
			}
		}
		if(chk)found=true;
	}
	
	
	
	
	bool found;
	
	int N,M;
	String[] S;
	public Sol(){
		var d=ria();
		N=d[0];M=d[1];
		S=new String[N];
		for(int i=0;i<N;i++)S[i]=rs();
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0