結果
問題 |
No.402 最も海から遠い場所
|
ユーザー |
![]() |
提出日時 | 2016-07-22 23:28:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,135 bytes |
コンパイル時間 | 864 ms |
コンパイル使用メモリ | 73,068 KB |
実行使用メモリ | 45,220 KB |
最終ジャッジ日時 | 2024-11-06 13:18:50 |
合計ジャッジ時間 | 9,254 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 TLE * 1 -- * 1 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <sstream> #include <iomanip> using namespace std; bool tof,tof2; int h, w; int solve(int cnt, vector<vector<int> > &land) { tof2 = false; for (int i = 1; i < h + 1; i++) { for (int j = 1; j < w + 1; j++) { if (land[i][j] == cnt) { tof = false; tof2 = true; for (int a = -1; a < 2; a++) { for (int b = -1; b < 2; b++) { if (land[i + a][j + b] < cnt) { tof = true; break; } } if (tof) break; } if (!tof) land[i][j]++; } } } if (!tof2) return cnt - 1; cnt = solve(++cnt, land); return cnt; } int main() { cin >> h >> w; vector<vector<int> > land; land.resize(h + 2); for (int i = 0; i < h + 2; i++) { if (i == 0 || i == h + 1) land[i].assign(w + 2, 0); else { land[i].resize(w + 2); land[i][0] = 0; land[i][w + 1] = 0; } } for (int i = 1; i < h + 1; i++) { for (int j = 1; j < w + 1; j++) { char tmp; cin >> tmp; if (tmp == '.') land[i][j] = 0; else if (tmp == '#') land[i][j] = 1; } } int cnt = 1; cout << solve(cnt, land) << endl; return 0; }