結果

問題 No.402 最も海から遠い場所
ユーザー AreTrashAreTrash
提出日時 2016-05-22 12:27:44
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,191 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 57,824 KB
実行使用メモリ 44,032 KB
最終ジャッジ日時 2024-04-24 03:06:10
合計ジャッジ時間 7,969 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 44 ms
6,400 KB
testcase_16 AC 81 ms
7,168 KB
testcase_17 AC 2,426 ms
25,856 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         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 };

bool isInside(int x, int y) {
    return 0 <= x && x < W + 2 && 0 <= y && y < H + 2;
}

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

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

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

    int ans = 0;

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

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