結果
問題 | No.402 最も海から遠い場所 |
ユーザー |
![]() |
提出日時 | 2016-08-07 14:36:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 3,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 3,034 ms |
コンパイル使用メモリ | 168,836 KB |
実行使用メモリ | 67,292 KB |
最終ジャッジ日時 | 2024-11-07 07:18:34 |
合計ジャッジ時間 | 3,895 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>template<typename T> T in() { abort(); return T(); }template<> std::string in() { std::string str; std::cin >> str; return str; }template<> int in() { int x; scanf("%d", &x); return x; }template<typename T> void out(T x) { abort(); }template<> void out(std::string x) { std::cout << x << std::endl; }template<> void out(int x) { printf("%d\n", x); }char field[4096][4096];int dp[4096][4096];int h, w;int main() {h = in<int>();w = in<int>();for(int i = 0; i < h; ++i) {scanf("%s", field[i]);}int res = 0;for(int i = 0; i < w; ++i) {if( field[0][i] == '#' ) {dp[0][i] = 1;res = 1;}}for(int i = 0; i < h; ++i) {if( field[i][0] == '#' ) {dp[i][0] = 1;res = 1;}}for(int i = 1; i < h; ++i) {for(int j = 1; j < w; ++j) {if( field[i][j] == '.' ) {dp[i][j] = 0;}else {dp[i][j] = 1 + std::min(dp[i][j-1], std::min(dp[i-1][j-1], dp[i-1][j]));res = std::max(dp[i][j], res);}}}out((res + 1) / 2);return 0;}