結果
| 問題 |
No.402 最も海から遠い場所
|
| コンテスト | |
| ユーザー |
AreTrash
|
| 提出日時 | 2016-05-22 12:18:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,190 bytes |
| コンパイル時間 | 461 ms |
| コンパイル使用メモリ | 58,004 KB |
| 実行使用メモリ | 45,288 KB |
| 最終ジャッジ日時 | 2024-11-06 09:53:14 |
| 合計ジャッジ時間 | 8,786 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 2 TLE * 2 -- * 3 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~
ソースコード
#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 >> W >> H;
int M = min(W, H) / 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;
}
AreTrash