結果
| 問題 |
No.402 最も海から遠い場所
|
| ユーザー |
sugim48
|
| 提出日時 | 2016-07-22 22:30:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,421 bytes |
| コンパイル時間 | 1,572 ms |
| コンパイル使用メモリ | 121,256 KB |
| 実行使用メモリ | 86,048 KB |
| 最終ジャッジ日時 | 2024-11-06 12:40:37 |
| 合計ジャッジ時間 | 4,279 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 7 WA * 12 |
ソースコード
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <unordered_set>
#include <vector>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
int INF = INT_MAX / 2;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
char c[3010];
int main() {
int H, W; cin >> H >> W;
vector<string> a(H);
for (int y = 0; y < H; y++) {
scanf("%s", c);
a[y] = c;
}
queue<i_i> q;
for (int y = 0; y < H; y++)
for (int x = 0; x < W; x++)
if (a[y][x] == '.')
q.push(i_i(y, x));
int t;
for (t = 0; !q.empty(); t++) {
queue<i_i> _q;
while (!q.empty()) {
i_i yx = q.front(); q.pop();
int y = yx.first, x = yx.second;
for (int dy = -1; dy <= 1; dy++)
for (int dx = -1; dx <= 1; dx++) {
int _y = y + dy, _x = x + dx;
if (0 <= _y && _y < H && 0 <= _x && _x < W && a[_y][_x] == '#') {
a[_y][_x] = '.';
_q.push(i_i(_y, _x));
}
}
}
q = _q;
}
cout << t - 1 << endl;
}
sugim48