結果

問題 No.402 最も海から遠い場所
ユーザー mamekinmamekin
提出日時 2016-10-07 12:57:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,042 ms / 3,000 ms
コード長 1,140 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 105,708 KB
実行使用メモリ 5,696 KB
最終ジャッジ日時 2023-08-14 01:16:11
合計ジャッジ時間 7,389 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 14 ms
4,380 KB
testcase_16 AC 19 ms
4,376 KB
testcase_17 AC 230 ms
4,444 KB
testcase_18 AC 450 ms
5,568 KB
testcase_19 AC 386 ms
5,120 KB
testcase_20 AC 2,042 ms
5,696 KB
testcase_21 AC 392 ms
5,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
        }
    }
}
0