結果

問題 No.402 最も海から遠い場所
ユーザー latte0119latte0119
提出日時 2016-07-22 22:33:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,492 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 164,980 KB
実行使用メモリ 229,876 KB
最終ジャッジ日時 2024-04-24 05:40:46
合計ジャッジ時間 5,984 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
74,240 KB
testcase_01 AC 56 ms
74,240 KB
testcase_02 AC 56 ms
74,496 KB
testcase_03 AC 55 ms
74,240 KB
testcase_04 AC 56 ms
74,240 KB
testcase_05 AC 55 ms
74,112 KB
testcase_06 AC 55 ms
74,240 KB
testcase_07 AC 56 ms
74,112 KB
testcase_08 AC 56 ms
74,240 KB
testcase_09 WA -
testcase_10 AC 55 ms
74,240 KB
testcase_11 AC 55 ms
74,368 KB
testcase_12 AC 55 ms
74,368 KB
testcase_13 AC 57 ms
75,264 KB
testcase_14 AC 56 ms
75,136 KB
testcase_15 WA -
testcase_16 AC 73 ms
78,720 KB
testcase_17 WA -
testcase_18 AC 624 ms
90,940 KB
testcase_19 AC 451 ms
229,876 KB
testcase_20 AC 460 ms
83,328 KB
testcase_21 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |     scanf("%lld%lld",&H,&W);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:26:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |     rep(i,H)scanf("%s",fld[i]);
      |             ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;
char fld[3010][3010];

int dist[3010][3010];

signed main(){
    scanf("%lld%lld",&H,&W);
    rep(i,H)scanf("%s",fld[i]);

    memset(dist,-1,sizeof(dist));

    queue<pint>que;

    rep(i,H)rep(j,W){
        if(fld[i][j]=='.'){
            dist[i][j]=0;
            que.push(pint(i,j));
        }
        else if(fld[i][j]=='#'&&(i==0||i==H-1||j==0||j==W-1)){
            dist[i][j]=1;
            que.push(pint(i,j));
        }
    }
    while(que.size()){
        int y,x;
        tie(y,x)=que.front();
        que.pop();
        for(int dy=-1;dy<=1;dy++){
            for(int dx=-1;dx<=1;dx++){
                int ny=y+dy,nx=x+dx;
                if(ny<0||ny>=H||nx<0||nx>=W||dist[ny][nx]!=-1)continue;
                dist[ny][nx]=dist[y][x]+1;
                que.push(pint(ny,nx));
            }
        }
    }
    int ma=0;
    rep(i,H)rep(j,W)chmax(ma,dist[i][j]);
    cout<<ma<<endl;
    return 0;
}
0