結果

問題 No.402 最も海から遠い場所
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2016-07-22 23:15:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,726 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 95,004 KB
実行使用メモリ 82,648 KB
最終ジャッジ日時 2024-04-24 06:03:14
合計ジャッジ時間 5,030 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
73,752 KB
testcase_01 AC 20 ms
73,628 KB
testcase_02 AC 20 ms
73,936 KB
testcase_03 AC 20 ms
73,840 KB
testcase_04 AC 21 ms
73,740 KB
testcase_05 AC 19 ms
73,796 KB
testcase_06 AC 19 ms
73,804 KB
testcase_07 AC 20 ms
73,880 KB
testcase_08 AC 21 ms
73,908 KB
testcase_09 AC 21 ms
73,836 KB
testcase_10 AC 19 ms
73,752 KB
testcase_11 AC 20 ms
73,832 KB
testcase_12 AC 20 ms
73,888 KB
testcase_13 AC 22 ms
74,004 KB
testcase_14 AC 20 ms
73,812 KB
testcase_15 AC 36 ms
74,144 KB
testcase_16 AC 44 ms
73,976 KB
testcase_17 AC 312 ms
77,980 KB
testcase_18 WA -
testcase_19 AC 579 ms
82,600 KB
testcase_20 WA -
testcase_21 AC 575 ms
82,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define along long(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[3003][3003];

int f(int y, int x) {
  if (y < 0 || x < 0)return 0;
  return d[y][x];
}

int main() {
  ll h, w;
  cin >> h >> w;
  vector<string> v;
  rep(i, 0, h) {
    string s;
    cin >> s;
    v.pb(s);
  }
  clr(d, 0);
  rep(y, 0, h) {
    rep(x, 0, w) {
      if (v[y][x] == '#') {
        d[y][x] = 1;
      }
    }
  }
  rep(y, 0, h) {
    rep(x, 1, w) {
      d[y][x] += d[y][x - 1];
    }
  }
  rep(y, 1, h) {
    rep(x, 0, w) {
      d[y][x] += d[y - 1][x];
    }
  }
  ll mx = 0;
  rep(y, 0, h) {
    rep(x, 0, w) {
      long long low = 0;
      long long high = 60;

      while (low < high) {
        long long mid = (high + low + 1) >> 1;

        ll count;
        count = f(y, x) - f(y - mid - 1, x) - f(y, x - mid - 1) + f(y - mid - 1, x - mid - 1);
        if (count == (mid + 1) * (mid + 1)) {
          low = mid;
        }
        else {
          high = mid - 1;
        }
      }
      mx = max(mx, (low + 2) / 2);
    }
  }
  cout << mx << endl;
  return 0;
}
0