結果

問題 No.402 最も海から遠い場所
ユーザー AreTrash
提出日時 2016-05-22 14:38:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,028 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 57,772 KB
実行使用メモリ 45,388 KB
最終ジャッジ日時 2024-11-06 09:54:08
合計ジャッジ時間 8,498 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 TLE * 1 -- * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         scanf("%s", c);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int W, H;
int map[3010][3010] = { 0 };
char c[3010];

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

int main(void)
{
    cin >> H >> W;
    int M = min(H, W) / 2;

    for (int i = 2; i <= H + 1; i++) {
        scanf("%s", c);
        for (int j = 2; j <= W + 1; j++) {
            if(c[j - 2] == '#') map[i][j] = 1510;
        }
    }

    for (int k = 0; k <= M; k++) {
        for (int i = 1; i <= H + 2; i++) {
            for (int j = 1; j <= W + 2; j++) {
                if (map[i][j] == k) {
                    for (int d = 0; d < 8; d++) {
                        map[i + dy[d]][j + dx[d]] = min(map[i + dy[d]][j + dx[d]], k + 1);
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 2; i <= H + 1; i++) {
        for (int j = 2; j <= W + 1; j++) {
            ans = max(ans, map[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}
0