結果
問題 | No.402 最も海から遠い場所 |
ユーザー |
![]() |
提出日時 | 2017-01-20 15:49:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 107 ms / 3,000 ms |
コード長 | 875 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 62,472 KB |
実行使用メモリ | 47,744 KB |
最終ジャッジ日時 | 2024-12-23 02:52:26 |
合計ジャッジ時間 | 2,425 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | REP(i,h) scanf("%s", g[i]); | ~~~~~^~~~~~~~~~~~ main.cpp: In function ‘int getInt()’: main.cpp:10:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | inline int getInt(){ int s; scanf("%d", &s); return s; } | ~~~~~^~~~~~~~~~
ソースコード
#include <iostream> #define IN(x,s,g) ((x) >= (s) && (x) < (g)) #define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h))) #include <cstring> #include <queue> #define REP(i,n) for(int i=0; i<(int)(n); i++) #include <cstdio> inline int getInt(){ int s; scanf("%d", &s); return s; } #include <set> using namespace std; int d[3010][3010]; char g[3010][3010]; inline int get(int x, int y, int w, int h) { return ISIN(x, y, w, h) ? d[y][x] : 0; } int main(){ const int h = getInt(); const int w = getInt(); REP(i,h) scanf("%s", g[i]); int ans = 0; REP(i,h) REP(j,w) { if (g[i][j] == '.') d[i][j] = 0; else d[i][j] = min(get(j - 1, i, w, h), min(get(j, i - 1, w, h), get(j - 1, i - 1, w, h))) + 1; ans = max(ans, d[i][j]); } // REP(i,h) { REP(j,w) printf("%02d ", d[i][j]); puts(""); } printf("%d\n", (ans + 1) / 2); return 0; }