結果
| 問題 |
No.402 最も海から遠い場所
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-07 12:57:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,212 ms / 3,000 ms |
| コード長 | 1,140 bytes |
| コンパイル時間 | 1,097 ms |
| コンパイル使用メモリ | 106,160 KB |
| 実行使用メモリ | 5,656 KB |
| 最終ジャッジ日時 | 2024-11-21 19:09:48 |
| 合計ジャッジ時間 | 6,874 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#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<bitset<3002> > s(h+2);
for(int y=1; y<=h; ++y){
for(int x=1; x<=w; ++x){
char c;
cin >> c;
if(c == '#')
s[y][x] = true;
}
}
int ans = 0;
for(;;){
++ ans;
for(int y=1; y<=h; ++y)
s[y] = s[y] & (s[y] << 1) & (s[y] >> 1);
vector<bitset<3002> > t(h+2);
bool isRest = false;
for(int y=1; y<=h; ++y){
t[y] = s[y] & s[y-1] & s[y+1];
isRest |= t[y].any();
}
s.swap(t);
if(!isRest){
cout << ans << endl;
return 0;
}
}
}