結果
問題 | No.402 最も海から遠い場所 |
ユーザー | mamekin |
提出日時 | 2016-10-07 12:59:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 680 ms / 3,000 ms |
コード長 | 1,449 bytes |
コンパイル時間 | 1,300 ms |
コンパイル使用メモリ | 110,316 KB |
実行使用メモリ | 85,928 KB |
最終ジャッジ日時 | 2024-05-01 14:45:28 |
合計ジャッジ時間 | 6,228 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 3 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 3 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 5 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 20 ms
5,376 KB |
testcase_16 | AC | 29 ms
5,376 KB |
testcase_17 | AC | 351 ms
25,512 KB |
testcase_18 | AC | 669 ms
16,256 KB |
testcase_19 | AC | 679 ms
85,928 KB |
testcase_20 | AC | 657 ms
12,672 KB |
testcase_21 | AC | 680 ms
49,540 KB |
ソースコード
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> using namespace std; int main() { int h, w; cin >> h >> w; vector<string> s(h+4, string(w+4, '.')); for(int y=0; y<h; ++y){ for(int x=0; x<w; ++x){ cin >> s[y+2][x+2]; } } h += 4; w += 4; queue<pair<int, int> > q; for(int y=1; y<h-1; ++y){ for(int x=1; x<w-1; ++x){ if(s[y][x] == '.') q.push(make_pair(y, x)); } } int ans = -1; while(!q.empty()){ int n = q.size(); while(--n >= 0){ int y, x; tie(y, x) = q.front(); q.pop(); for(int dy=-1; dy<=1; ++dy){ for(int dx=-1; dx<=1; ++dx){ int y2 = y + dy; int x2 = x + dx; if(s[y2][x2] == '#'){ s[y2][x2] = '.'; q.push(make_pair(y2, x2)); } } } } ++ ans; } cout << ans << endl; return 0; }