結果

問題 No.402 最も海から遠い場所
ユーザー h_nosonh_noson
提出日時 2016-07-22 23:59:49
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,848 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 71,216 KB
最終ジャッジ日時 2024-04-27 02:21:47
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:25:23: error: ‘acos’ was not declared in this scope
   25 | constexpr double PI = acos(-1);
      |                       ^~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;
constexpr int ESP = 1e-9;
constexpr double PI = acos(-1);

string s[3000];
int dist[3000][3000];
bool used[3000][3000];
int dxy[] = {0,1,-1,-1,0,-1,1,1};
int h, w;

int main(void) {
    int i, j;
    cin >> h >> w;
    REP (i,h) cin >> s[i];

    REP (i,h) REP (j,w) dist[i][j] = INF;
    queue<pair<int,pair<int,int>>> q;
    REP (i,h) REP (j,w) if (s[i][j] == '.') {
        q.push(make_pair(0,make_pair(i,j)));
        dist[i][j] = 0;
    }
    REP (i,h) REP (j,w) {
        if (s[i][j] == '#' && (i == 0 || i == h-1 || j == 0 || j == w-1)) {
            q.push(make_pair(1,make_pair(i,j)));
            dist[i][j] = 1;
        }
    }
    while (!q.empty()) {
        int d = q.front().first;
        int y = q.front().second.first;
        int x = q.front().second.second;
        q.pop();
        REP (i,8) {
            int ny = y + dxy[i];
            int nx = x + dxy[(i+1)%8];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (dist[ny][nx] > d + 1) {
                q.push(make_pair(d+1,make_pair(ny,nx)));
                dist[ny][nx] = d + 1;
            }
        }
    }
    int ans = 0;
    REP (i,h) REP (j,w) ans = max(ans,dist[i][j]);
    cout << ans << endl;
    return 0;
}
0