結果
| 問題 |
No.402 最も海から遠い場所
|
| コンテスト | |
| ユーザー |
🍡yurahuna
|
| 提出日時 | 2016-07-22 23:12:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 865 ms / 3,000 ms |
| コード長 | 1,577 bytes |
| コンパイル時間 | 1,838 ms |
| コンパイル使用メモリ | 174,412 KB |
| 実行使用メモリ | 144,256 KB |
| 最終ジャッジ日時 | 2024-11-06 13:05:23 |
| 合計ジャッジ時間 | 6,780 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long // <-----!!!!!!!!!!!!!!!!!!!
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define printV(v) for(auto&& x : v){cerr << x << " ";} cerr << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cerr << x << " ";}cerr << endl;}
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;
VV rot(const VV& a) {
int h = a.size();
int w = a[0].size();
VV b(w, V(h));
rep(i, h) {
rep(j, w) {
b[w - j - 1][i] = a[i][j];
}
}
return b;
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int H, W;
cin >> H >> W;
VV a(H + 2, V(W + 2, 0));
rep2(i, 1, H + 1) {
string s;
cin >> s;
rep(j, W) {
a[i][j + 1] = (s[j] == '#' ? inf : 0);
}
}
rep(t, 4) {
rep2(i, 1, H + 1) {
rep2(j, 1, W + 1) {
a[i][j] = min<int>({a[i][j], a[i - 1][j] + 1, a[i][j - 1] + 1, a[i - 1][j - 1] + 1});
}
}
a = rot(a);
swap(H, W);
}
int ma = -1;
rep(i, H + 2) ma = max(ma, *max_element(all(a[i])));
cout << ma << endl;
}
🍡yurahuna