結果

問題 No.402 最も海から遠い場所
ユーザー highd
提出日時 2016-09-07 20:26:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,181 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 66,700 KB
実行使用メモリ 45,344 KB
最終ジャッジ日時 2024-11-15 21:09:35
合計ジャッジ時間 32,443 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 RE * 1 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
inline int max(int a, int b) {
	return a>b?a:b;
}
/**/
int main() {
	int height,width;
	std::cin>>height>>width;
	height+=2;
	width +=2;
	int*map=new int[height*width];
	char ch=0;
	int index=0;
	for (int i = 0; i < width; i++) {
		map[index]=-1;
		index++;
	}
	index--;
	while (ch!=EOF) {
		if(index>=height*width-width)break;
		if (index%width == width - 1) {
			map[index+1]=-1;
			map[index] = -1;
			index+=2;
		}
		ch=getchar();
		switch (ch) {
		case '.':
			map[index]=-1;
			index++;
			break;
		case '#':
			map[index]= 4000;
			index++;
		default:
			break;
		}
	}
	for (int i = 0; i < width; i++) {
		map[index] = -1;
		index++;
	}
	for (int x1 = 0; x1 < width; x1++) {
		for (int y1 = 0; y1 < height; y1++) {
			if (map[x1 + y1*width] == -1) {
				for (int x2 = 0; x2 < width; x2++) {
					for (int y2 = 0; y2 < height; y2++) {
						if (map[x2 + y2*width]!=0&&map[x2 + y2*width] > max(abs(x1 - x2), abs(y1 - y2))) {
							map[x2 + y2*width]= max(abs(x1 - x2), abs(y1 - y2));
						}
					}
				}
			}
		}
	}
	int max=0;
	for (int i = 0; i < height*width; i++) {
		if (max < map[i]) {
			max=map[i];
		}
	}
	std::cout<<max<<std::endl;
	return 0;
}
0