結果
| 問題 |
No.402 最も海から遠い場所
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-07-23 00:46:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 955 bytes |
| コンパイル時間 | 623 ms |
| コンパイル使用メモリ | 64,980 KB |
| 実行使用メモリ | 45,476 KB |
| 最終ジャッジ日時 | 2024-11-06 13:14:24 |
| 合計ジャッジ時間 | 7,403 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 TLE * 1 -- * 1 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool tof,tof2;
int h, w;
int solve(int cnt, vector<vector<int> > &land) {
tof2 = false;
for (int i = 0; i < h+2; i++) {
for (int j = 0; j < w + 2; j++) {
if (land[i][j] == cnt) {
for (int a = -1; a < 2; a++) {
for (int b = -1; b < 2; b++) {
if (i + a > h + 1 || j + b > w + 1 || i + a < 0 || j + b < 0) continue;
if (land[i + a][j + b] == 1) {
tof2 = true;
land[i + a][j + b] = cnt + 2;
}
}
}
}
}
}
if (!tof2) return cnt;
cnt = solve(cnt+2, land);
return cnt;
}
int main()
{
cin >> h >> w;
vector<vector<int> > land;
land.resize(h + 2);
for (int i = 0; i < h + 2; i++) {
land[i].resize(w+2);
}
for (int i = 1; i < h + 1; i++) {
string s;
cin >> s;
for (int j = 0; j < w; j++) {
if (s[j] == '#') land[i][j+1] = 1;
}
}
int cnt = 0;
cout << solve(cnt, land)/2 << endl;
return 0;
}
kurenai3110