結果

問題 No.402 最も海から遠い場所
ユーザー chakkuchakku
提出日時 2016-09-11 20:42:58
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,469 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 169,844 KB
実行使用メモリ 12,188 KB
最終ジャッジ日時 2024-04-28 12:12:33
合計ジャッジ時間 7,638 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int dx[8]={0,-1,-1,-1,0,1,1,1};
const int dy[8]={1,1,0,-1,-1,-1,0,1};

int H,W;
vector<string> S;

int dis(pii a,pii b){
    int x = abs(a.first - b.first);
    int y = abs(a.second - b.second);
    return max(x,y);
}

int main(){
    set<pii> sea,land;
    cin >> H >> W;
    S.resize(H+2);
    for(int i=1;i<=H;i++){
        string s;cin>>s;
        S[i] = "." + s + ".";
    }
    string dot(W+2,'.');
    S[0]=dot;
    S[H+1]=dot;

    for(int i=0;i<S.size();i++){
        for(int j=0;j<S[i].size();j++){
            if(S[i][j]=='.') sea.insert(MP(i,j));
            else land.insert(MP(i,j));
        }
    }


    int ans = 1;
    for(pii v:land){
        int dmin=INF;
        for(pii u:sea){
            dmin= min(dmin,dis(u,v));
        }
        ans = max(ans,dmin);
    }
    cout << ans << endl;
}
0